PowerShell - Shutting down a program normally

December 2016


I want to close a program (simulate File > Close > Exit menu) with PowerShell.

So far I'm using the stop-process command. But in fact it just kill the process and programs like Firefox are being affected.

So are there any command that will allow a clean shutdown.


Try this:

get-process name_of_program | %{ $_.closemainwindow() } 

Related :

This document entitled « PowerShell - Shutting down a program normally » from CCM (ccm.net) is made available under the Creative Commons license. You can copy, modify copies of this page, under the conditions stipulated by the license, as this note appears clearly.