Basically I am a batch file for a shell which triggers a powershell script to launch Google Chrome. I want to system to logoff when Chrome is closed. Here is my script:<\/p>\n
#shell<\/span>.ps1 However, the system logs off while Chrome is still running.<\/p>\n Any suggestions?<\/p>\n Cheers<\/p>","upvoteCount":4,"answerCount":3,"datePublished":"2020-04-29T20:41:04.000Z","author":{"@type":"Person","name":"jamespreston","url":"https://community.spiceworks.com/u/jamespreston"},"suggestedAnswer":[{"@type":"Answer","text":" Basically I am a batch file for a shell which triggers a powershell script to launch Google Chrome. I want to system to logoff when Chrome is closed. Here is my script:<\/p>\n #shell<\/span>.ps1 However, the system logs off while Chrome is still running.<\/p>\n Any suggestions?<\/p>\n Cheers<\/p>","upvoteCount":4,"datePublished":"2020-04-29T20:41:04.000Z","url":"https://community.spiceworks.com/t/powershell-script-to-logoff-when-chrome-is-closed/760944/1","author":{"@type":"Person","name":"jamespreston","url":"https://community.spiceworks.com/u/jamespreston"}},{"@type":"Answer","text":" Hi jpreston<\/p>\n If you post code, please use the ‘Insert Code’ button. Please and thank you!<\/p>
\n& ‘C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe’ -d5000 www.msdsonline.com<\/a>
\nsleep -s 15
\nwhile(get-process Google Chrome){sleep -s 10}
\n& ‘C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe’ /terminate
\nlogoff.exe<\/p>\n
\n& ‘C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe’ -d5000 www.msdsonline.com<\/a>
\nsleep -s 15
\nwhile(get-process Google Chrome){sleep -s 10}
\n& ‘C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe’ /terminate
\nlogoff.exe<\/p>\n