Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

powershell close internet explorer gracefully / cleanly

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.

like image 842
Kam0106 Avatar asked Jul 23 '12 10:07

Kam0106


People also ask

How do I close Internet Explorer with PowerShell?

Open Start. Search for PowerShell, right-click the top result, and select the Run as administrator option. Type the following command to disable Internet Explorer 11 and press Enter: Disable-WindowsOptionalFeature -FeatureName Internet-Explorer-Optional-amd64 –Online.

How do I use Taskkill in PowerShell?

Kill a process with Taskkill Taskkill allows you to kill a process either by its PID or by the name listed for it in the tasklist output. To stop a process by its ID, use taskkill /F /PID <PID> , such as taskkill /F /ID 312 7 if 3127 is the PID of the process that you want to kill.

How do I close a Windows program in PowerShell?

Killing a process with TASKKILL At the basic level, TASKKILL is like clicking the X button on the top-right corner of any Windows application. It will “gracefully” exit the program and will prompt you “whether to save changes” before exiting.


1 Answers

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() }
like image 148
Shay Levy Avatar answered Oct 05 '22 04:10

Shay Levy