powershell close internet explorer gracefully / cl

2019-04-09 03:00发布

I would like to close internet explorer cleanly/ gracefully. A taskkill would close it but when re-opening it it will ask if you want to re-open the last session.

3条回答
干净又极端
2楼-- · 2019-04-09 03:28

Try this: get-process iexplore | stop-process.

查看更多
狗以群分
3楼-- · 2019-04-09 03:31

This will loop around and call CloseMainWindow on all its windows, that is the graceful shutdown api call - it sleeps half a second to give it time to close each before going around:

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}"

查看更多
beautiful°
4楼-- · 2019-04-09 03:54

Try the CloseMainWindow method: Closes a process that has a user interface by sending a close message to its main window.

Get-Process iexplore | Foreach-Object { $_.CloseMainWindow() }
查看更多
登录 后发表回答