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:
[powershell]
Get-Process notepad | % { $_.CloseMainWindow() }
[/powershell]
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…
I don’t know the first thing about Powershell, although someday I hope to learn it. In the meantime, I’ve been looking for a script that will
1. pass a ‘close’ command to a running program (wlmail.exe) (the program’s own close routine first destroys the UI, then conducts some internal housekeeping before the process ends);
2. display a message box saying that WLMail is saving your data;
3. remove that message box when the process ends normally.
The script would ideally be invoked by, say, clicking a button on the desktop that is created when the wlmail.exe process starts.
Is this feasible, do you think?