Kill processes using command prompt in Windows 7

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.

Credit: Tasklist and Taskkill ~ A Command line equivalent Task Manager utility

3 thoughts on “Kill processes using command prompt in Windows 7

  1. Many thanks for this great post. We were using a Java based SSH tunnel client that would open a new process for each session started. Once there are many processes, new process will not start and we would have to kill each manually one after the other. Using this command (taskkill /IM java.exe /F) , saved us so much time to kill all Java processes. Works like charm. 🙂

    Like

  2. Thanks for the advice.
    Unfortunately I did try it on an instance of skype that was hung and even if the command said it was succesfull this was not the case.

    C:UsersMU>taskkill /IM Skype.exe /F
    SUCCESS: The process “Skype.exe” with PID 7324 has been terminated.

    C:UsersMU>taskkill /IM Skype.exe /F
    SUCCESS: The process “Skype.exe” with PID 7324 has been terminated.

    C:UsersMU>taskkill /IM Skype.exe /F
    SUCCESS: The process “Skype.exe” with PID 7324 has been terminated.

    C:UsersMU>taskkill /IM Skype.exe /F
    SUCCESS: The process “Skype.exe” with PID 7324 has been terminated.

    Do you know if there it is anything more powerful that I can use except restarting Windows 7?

    Like

Leave a comment