TaskKill: Kill process from command line (CMD)

We can kill a process from GUI using Task manager. If you want to do the same from the command line, then taskkill is the command you are looking for. This command has options to kill a task/process either by using the process id or by the image file name.

Windows 10 and Windows 11: The taskkill command and the examples below work on both versions.

Kill a process using image name:

We can kill all the processes running a specific executable using the below command.

taskkill /IM executablename

Example:
Kill all processes running mspaint.exe:

c:>taskkill /IM mspaint.exe
SUCCESS: Sent termination signal to the process "mspaint.exe" with PID 1972.

Kill a process forcibly

In some cases, we need to forcibly kill applications. For example, if we try to kill Internet Explorer with multiple tabs open, tasklist command would ask the user for confirmation. We would need to add /F flag to kill IE without asking for any user confirmation.

taskkill /F /IM iexplore.exe

/F : to forcibly kill the process. If not used, in the above case it will prompt the user if the opened pages in tabs need to be saved.

Advertisement

To kill Windows explorer, the following command would work

C:>taskkill /F /IM explorer.exe
SUCCESS: The process "explorer.exe" with PID 2432 has been terminated.

The above command would make all GUI windows disappear. You can restart explorer by running ‘explorer’ from cmd.

C:>explorer

Not using /F option, would send a terminate signal. In Windows 7, this throws up a shutdown dialog to the user.

C:>taskkill /IM explorer.exe
SUCCESS: Sent termination signal to the process "explorer.exe" with PID 2432.
C:>

Kill a process with process id:

We can use the command below to kill a process using process ID (PID).

taskkill /PID  processId

Example:
Kill a process with PID 1234.

taskkill /PID 1234

Kill processes consuming a high amount of memory

taskkill /FI "memusage gt value"

For example, to kill processes consuming more than 100 MB memory, we can run the below command

taskkill /FI "memusage gt 102400"

More examples

Sometimes applications get into hung state when they are overloaded or if the system is running with low available memory. When we can’t get the application to usable state, and closing the application does not work, what we usually tend to do is kill the task/process. This can be simply done using taskkill command.

To kill Chrome browser from CMD

Taskkill /F /IM Chrome.exe

Kill ChromeDriver from command line

Taskkill /F /IM Chromedriver.exe

To kill Firefox browser application

taskkill /F /IM firefox.exe

To kill MS Word application(Don’t do this if you haven’t saved your work)

taskkill /F /IM WinWord.exe

Sometimes, the command window itself might not be responding. You can open a new command window and kill all the command windows

taskkill /F /IM cmd.exe

This even kills the current command window from which you have triggered the command.

Advertisement

35 thoughts on “TaskKill: Kill process from command line (CMD)”

  1. Hi,

    i have a question about this.
    I have a process that runs in my domain that puts outlook suspended. As soon as I do a task kill forced as administrator it runs.

    I wrote a little script, now i want to add admin rights to the script via GPO.

    Can you help me with that?

    Kind regards,

    Karim

    Reply
  2. Hello,

    I want to kill 3 images once a condition is matches,
    taskkill /fi “USERNAME eq %USERNAME%” /im java.exe ssonsvr.exe wfshell.exe

    could anyone tell me what is the right syntax to do so?

    Thanks

    Reply
    • FOR %I IN (java.exe ssonsvr.exe wfshell.exe) DO taskkill /fi “USERNAME eq %USERNAME%” /im %I
      Use %%I if it is included in a batch

  3. How can keep the line below from showing in the open DOS box?

    SUCCESS: The process “program.exe” with PID 2868 has been terminated.

    Reply
  4. im just saying on admin cmd command like this: (taskkill /f /im wininit.exe /t ) and my windows frezze and blue screen of death hehehe im was very stupid

    Reply
  5. I didn’t see how to kill specific file.
    for example i have three A.docx, B.docx, and C.docx files and I want kill just A.docx.
    if I use taskkill /IM winword.exe then I will kill all of them.

    Reply
    • When you kill with image name, it kills every process so all files would be closed. To kill a Word session for a specific file, use the process id.

  6. I use this command: taskkill /IM iperf.exe /F from regular command line window and it fails but when I run same command from command line that was run as administrator – it works fine – why and what can be done?

    Reply
  7. Open command prompt with administrator

    in command prompt, type following command
    taskkill /IM Excel.exe

    and press enter

    Reply
  8. how to kill my Wifi or internet access if my VPN dies? I mean there is a specific task to kill-close immediately my internet?

    Reply
  9. Please how to kill a program as administrator.
    I have created a cmd file with the comand taskkill /im programname /f
    but it doesn’t kill the program, so put at the end the comand pause to see what happened
    and have noticed that it gave me access denied.
    Please how can i do?
    Thanks
    Enzo

    Reply
    • Use Taskkill /t /f /im `your cmd file name`
      /t terminate all process including sub-ones
      /f with force
      /im with image name

    • With the most recent version of Windows 11 Pro x64, in the Task Manager, Details section, if you right-click on a process or exe, it now gives you the option to “restart” the task. Is there a command line version of the “restart” command? I know taskkill.exe can stop the process, and start.exe can start one, but is there one combined command to stop, then restart it?

  10. is there any way to kill specific tab of chrome through this taskkill as if we use chrome.exe to kill ,it will terminate all the processes.

    Reply
  11. I have a program and when I close that, it displays a OK / Cancel message window. How can I pass ‘OK’ to TASKKILL command. Please help……

    Reply
  12. I dont want to open cmd every time is it possible to make a .bat file that can auto-kill the process?
    for example:
    taskkill /f /im GTA5.exe

    Reply
    • Yes. Create a batch file with your command. Store the batch file in a folder on the hard drive. Create a shortcut to the batch file and place it on your desktop. Right-Click the Shortcut, go to Properties, Advanced, and check the box that says “Run as Administrator”. Save the shortcut. Now when you open the shortcut, you will get the prompt to Run As Administrator, then you just click “Yes”. Even with admin rights, you will still get the prompt.

  13. How to kill a process based on command line, since many process run with same name.
    Example ade.exe ade.exe, I want to kill only one based on command line. I’m not supposed to use pid to kill the process

    Reply
  14. Why can’t I get this to kill all cmd.exe?

    taskkill /f /im cmd.exe will only work on a single instance. If you have more than 1 instance it will not kill any instances.

    Reply

Leave a Comment