I was working on a startup script this morning and needed a way for the script to kill one process before starting up a new process. I’ve used pskill.exe in the past, but wanted to find out if there were any built-in tools in Windows 7 before resorting to Sysinternals components.
It just so happens that Windows 7 comes with a program called taskkill.exe that does exactly what I need in a no muss, no fuss manner.
Here’s how to use this utility from the command line or from a script — there are several options available, but this is what I landed on:
taskkill /IM javaw.exe /F
- The /IM flag tells taskkill that you want to kill all processes with an Image name of “javaw.exe”.
- The /F flag indicates that you want to force close the application rather than playing nice, for example bypassing any shutdown dialogs that may be shown by a GUI during a normal exit.
You can also use the process ID and kill processes on remote computers — type taskkill /? in a cmd window to see the complete list of options.