Terminate multiple programs from the command line with Taskkill

Martin Brinkmann
Mar 8, 2015
Tutorials
|
4

Not all program termination options work all the time. If a program is not responding, you may not be able to use the window close button to terminate it. The same may be true for killing the process in the Windows Task Manager.

Taskkill is a versatile command line tool that you can use for these purposes. Among the many features that it supports is an option to close programs forcefully and to terminate multiple programs in a single operation.

Especially the latter can be useful if you need to clear rogue programs on your system that spawn new processes as soon as you terminate them.

The basic command is taskkill followed by parameters. A good starting point is to run taskkill /? to display the help text listing all parameters that you can use.

To terminate a process, you can use the following two core options:

  1. taskkill /IM explorer.exe
  2. taskkill /PID 1516

The first refers to the image name of the program running which you get when you run tasklist on the command line or by using the Windows Task Manager. The second the process ID of the process which you get in the same way.

Using the image name will kill all processes of that name. The process ID on the other hand allows you to select a specific process instead.

To terminate multiple processes at once use the following command.

  1. taskkill /PID 123 /PID 234 /PID 345

The parameter /f specifies that the selected processes should be terminated forcefully while /t that all of its child processes should be terminated along with it.

What makes taskkill particularly powerful is its filtering system. You can use filters to terminate matching processes to kill a whole batch of them at the same time.

Filters use the /fi parameter followed by instructions what you want to filter. The operators used here are:

  1. eq equal
  2. ne not equal
  3. gt greater than
  4. lt less than
  5. ge greater or equal
  6. le lesser or equal

Interesting filter names are IMAGENAME, CPUTIME, MEMUSAGE or USERNAME among others (see screenshot above for all of them and the operators they support).

As you can see, wildcards are supported. You can only use wildcards for /IM when at least one filter is specified.

Some examples:

  1. taskkill /FI "STATUS eq NOT RESPONDING"
  2. taskkill /FI "USERNAME eq MARTIN"
  3. taskkill /s servername /FI "IMAGENAME eq rog*" /im *

What they do

  1. Terminates all running processes with the status not responding
  2. Terminates all running processes by the user MARTIN
  3. Terminates all image names starting with rog on the server servername

You use the parameters /p and /u to set a password and username if necessary.  The user parameter comes in the form Domain\User e.g. /u coredomain\martin /p secretpassword

Additional information are provided on Microsoft's Technet website

Summary
Terminate multiple programs from the command line with Taskkill
Article Name
Terminate multiple programs from the command line with Taskkill
Description
Find out how to kill multiple programs or processes from the Windows command line in a single operation.
Author
Advertisement

Previous Post: «
Next Post: «

Comments

  1. Manuel said on May 13, 2015 at 1:39 am
    Reply

    God tip, or can download my application to close any process by name or multiples process that match by name, example resetapp.exe -close “excel” -issequence true close all open excel process (multiple session of the program) http://marjuanm.blogspot.mx/2015/04/resetapp-reiniciando-o-cerrando.html

  2. Jeff said on March 8, 2015 at 6:29 pm
    Reply

    I do this with Autohotkey, and assign various kills to hotkeys. It’s a good way to avoid “are you sure you want to close this?” nags

  3. exrelayman said on March 8, 2015 at 4:10 pm
    Reply

    A question: In the image illustrating /?, the expression FI appears in the 4th and 5th examples. FI is not explained in the text or image, so I was hoping you or a fellow reader would explain it to me. I’m sorry if I am being dense!

    A remark: The neat little program ‘close all’ does close all running programs provided nothing malicious is going on and is pretty handy: http://www.ntwind.com/software/utilities/close-all.html

    1. Martin Brinkmann said on March 8, 2015 at 7:18 pm
      Reply

      /FI is the filter argument and what follows specifies that filter.

Leave a Reply

Check the box to consent to your data being stored in line with the guidelines set out in our privacy policy

We love comments and welcome thoughtful and civilized discussion. Rudeness and personal attacks will not be tolerated. Please stay on-topic.
Please note that your comment may not appear immediately after you post it.