How to send Shutdown command to process through CMD Prompt on Windows How to send Shutdown command to process through CMD Prompt on Windows windows windows

How to send Shutdown command to process through CMD Prompt on Windows


Tested on Windows 7:

taskkill /IM notepad.exe

Note that you have to specify the .exe extension. I assume this does what you need: It doesn't simply kill the process, but sends the "shutdown" signal, which will display the "Save unsaved changes?" dialog in Notepad and other editors.


If your application support the standard windows messages for it you could use rmtool to lie to the application and tell it that the computer is shutting down. See How to simulate Windows shutdown for debugging?

To script it you will need to find the PID of the process before (pslist from sysinternals give the information but you will need to parse the result).

And if they don't cleanly shutdown just do as windows do when it close : Use rmtool to ask all of them to quit nicely then 30s latter kill everyone still standing (For both outlook and devenv it might even be a little short...).