Powershell close Internet explorer gracefully / cleanly

I would like to close the internet browser cleanly / elegantly. Taskkill will close it, but when you reopen it, it will ask if you want to reopen the last session.

+5
source share
3 answers

Try the CloseMainWindow method: closes the process with the user interface by sending the tag message to the main window.

Get-Process iexplore | Foreach-Object { $_.CloseMainWindow() }
+7
source

Try the following: get-process iexplore | stop-process.

+3
source

CloseMainWindow , api- - , , , :

powershell -Command "while ($true){Try{$process=Get-Process iexplore -ErrorAction Stop}Catch [Microsoft.PowerShell.Commands.ProcessCommandException]{break;}if ($process) {$whateva=$process.CloseMainWindow()}else {break;}Start-Sleep -m 500}"

0

All Articles