Techibee.com

Close applications gracefully using powershell

By saying “Graceful” close, I mean allowing the users to save any un saved data before exiting the application. It is equivalent to clicking on “CLOSE” button at the right top corner. The advantage with this method when compared “stop-process” is, it allows the user to save data and hence there is no data lose.

This option came handy to me several time.

Code:

Get-Process notepad | % { $_.CloseMainWindow() }

The above code will get list of  notepad processes running in your PC and prompts you to save data for the processes which have unsaved content. The notepad processes which don’t have anything to save will get closed normally.

Hope this helps you…

Exit mobile version