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

2 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. :)

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>