How to kill a windows task at the command line.
By Mike on Mar 13, 2008 in How to, Windows
Someone here at the office just asked me how to kill a process in XP at the command line. Presumably they wanted to kill a process in a batch file. Seeing I had to look it up myself, I thought it might be useful to you too.
If you know the name of a process to kill, for example sol.exe (the solitaire game), use the following command from a command prompt to kill it:
taskkill /IM sol.exe
The /IM switch will cause the program to terminate gracefully, asking for confirmation if there are unsaved changes. To forcefully kill the same process, add the /F option to the command line. Be careful with the /F option as it will terminate all matching processes without confirmation.
To kill a single instance of a process, specify its process id (PID). For example, if the desired process has a PID of 810, use the following command to kill it. Use the PID if you have more then one copy of the process running:
taskkill /PID 810
Side note for newbies: For those of you still new to computers, you can access command line by going to start – run, type cmd in the space given and then hit ok.







SAK | Mar 31, 2009 | Reply
This is a very useful post. Thanks.
There is an inaccuracy above:
/IM “Specifies the image name of the process that has to be terminated. Wildcard ‘*’ can be used to specify all image names.”
/F “Specifies to forcefully terminate process(es)”
i.e. you need /IM to specify a process by name (e.g. sol.exe instead of /PID 810 if you know that an instance of sol.exe is running as PID 810), but /IM doesn’t in itself ask for graceful termination. Rather, a process won’t be terminated forcefully unless /F is specified.
taskkill /? provides information on a number of other potentially useful option switches