XP: kill a Windows process from the command line with taskkill

The ability to perform tasks from a system’s command line allows those tasks to be used in batch files. This recipe describes several uses of taskkill to terminate Windows processes.


If you know the name of a process to kill, for example notepad.exe, use the following command from a command prompt to end it:

taskkill /IM notepad.exe

This 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 827, use the following command to kill it:

taskkill /PID 827

Using filters, a variety of different patterns can be used to specify the processes to kill. For example, the following filter syntax will forcefully kill all processes owned by the user Quinn:

taskkill /F /FI "USERNAME eq Quinn"

The following table shows the available filters and their use.

Filter Name Valid Operators Valid Value(s)
----------- --------------- --------------
STATUS eq ne RUNNING | NOT RESPONDING
IMAGENAME eq ne Image name
PID eq ne gt lt ge le PID value
SESSION eq ne gt lt ge le Session number.
CPUTIME eq ne gt lt ge le CPU time in the format
of hh:mm:ss.
MEMUSAGE eq ne gt lt ge le Memory usage in KB
USERNAME eq ne User name in [domain\]user
format
MODULES eq ne DLL name
SERVICES eq ne Service name
WINDOWTITLE eq ne Window title

eq: equals ne: not equal
gt: greater than lt: less than
gt: greater than or equal le: less than or equal

 

About Quinn McHenry

Quinn was one of the original co-founders of Tech-Recipes. He is currently crafting iOS applications as a senior developer at Small Planet Digital in Brooklyn, New York.
View more articles by Quinn McHenry

The Conversation

Follow the reactions below and share your own thoughts.

93 Responses to “XP: kill a Windows process from the command line with taskkill”

  1. October 06, 2008 at 9:36 pm, coder said:

    Check for hardware or memory faults. If there are hardware issues then it will slowly corrupt your OS in odd ways eventually causing it to crash more often.

    Also check for driver issues/conflicts. If a device keeps making hardware interrupt calls it will force the system to respond but if the driver is not going to respond properly it may freeze or just take forever to come back.

    Reply

  2. October 11, 2008 at 5:57 pm, Kevski said:

    anyone know which service is associated with this? I get the following reply when I run this from the cmd line:
    TASKKILL /F/ IM DTFMON.EXE

    “ERROR: The service cannot be started, either because it is disabled or because it has no enabled devices associated with it.”

    Reply

    • May 12, 2009 at 11:35 pm, Breno said:

      Taskkill uses WMI API to search process by name. Enable Windows Management Instrumentation (winmgmt) to use /IM.

      Reply

  3. October 24, 2008 at 8:28 pm, farouk said:

    good article
    i cant find this command on xp, what to do??

    Reply

  4. November 07, 2008 at 1:43 pm, Dez said:

    awesome, thanks m8

    Reply

  5. November 17, 2008 at 2:07 pm, Dev said:

    taskkill doesnt work for me!!

    Reply

  6. December 16, 2008 at 2:08 am, Hern said:

    I prefer using Daphne which has it’s own command line tool for listing and killing processes.

    Reply

  7. December 17, 2008 at 6:48 pm, seg said:

    am not getting exactly…and in my cmd its not working…can u mail me?

    matrixjon42@yahoo.com

    Reply

  8. December 18, 2008 at 9:00 pm, deen said:

    wow very short are there any simple technique to kill the process

    Reply

  9. December 23, 2008 at 9:09 am, ADSF said:

    TRY /F FOR ANOTHER USERS PROCESS KILLING , GR8 FUN TO DO SO ;)

    Reply

  10. January 02, 2009 at 4:05 pm, Anonymous said:

    tskill works.

    Reply

  11. January 03, 2009 at 9:16 pm, Dan said:

    “gt: greater than or equal le: less than or equal”

    This is incorrect. “ge” is greater than or equal.

    Dan

    Reply

  12. February 15, 2009 at 9:48 am, aathisankar said:

    Thanks a lot .. i have been searching for this command a week//
    It was really useful for my project … :-)

    Reply

  13. March 28, 2009 at 6:57 am, Vivek said:

    thanks ,really i got what expected

    Reply

  14. April 08, 2009 at 6:09 am, swapnil said:

    Really cool… thanks for the help….. Toad 9 sucks

    Reply

  15. May 07, 2009 at 5:34 am, Nikhil Bhatt said:

    Thanks Guys This Command Helped Me A LOT !!!!!!

    Thanks once again !!!!

    Reply

    • May 11, 2009 at 5:17 pm, Rama said:

      I try this and nothing happen. Where do I see changes? But now computer make the grinding noise all time. How to undo command?

      Reply

  16. June 08, 2009 at 12:14 am, GFYM said:

    only in XP Pro, not in XP Home

    Reply

    • November 28, 2012 at 8:55 pm, Mike said:

      Yeah, only XP Pro! Another dumb solution!

      It works in Windows 7 Premium, though.

      Reply

  17. June 10, 2009 at 7:37 pm, fgf said:

    Sooo how do i shutdown fortiguard and stuff at school to get past internet filter?

    Reply

  18. June 22, 2009 at 2:22 pm, kelvin said:

    Hello oooo!

    I just want to thank you guy for the content of the site i just click on it and on like other sites i have been i didnt regret it..

    i really learnt new stuff especially based on programming (straight shit now long talks … good examples)

    just wanna know how i can join the crew…
    men you guys are the boooomb… keep it up.
    thanks
    Kelvin.

    Reply

  19. June 28, 2009 at 6:52 pm, Tichomir Mitkov said:

    cool, man !

    Reply

  20. July 01, 2009 at 5:37 am, pawan said:

    How to the wht is PID of a process

    Reply

  21. July 05, 2009 at 11:31 am, Vesa said:

    On Vista (Premium) cmd: taskkill /F /FI “USERNAME eq Quinn” messes up the explorer.exe .. :)

    Reply

  22. July 08, 2009 at 6:49 pm, Fernando said:

    cool :) Really Thanks

    Reply

    • July 12, 2009 at 4:29 pm, Anonymous said:

      How about killing only the last instance of the program and not the first on

      Reply

  23. July 14, 2009 at 6:31 am, morph said:

    @thedylman These utilities are available only for xp pro.
    You can couple it with the tasklist /SVC command to see the process id of the process and then use taskkill on it that way you can be sure of the process you are terminating and can also spot malwares. See this link

    Reply

  24. July 27, 2009 at 2:26 pm, Anonymous said:

    I guess you learn new things every day. I’ve been using the command line for years, and I didn’t know about this. I’ve always been using tskill, though I suppose there is little difference in the end, eh?

    Reply

  25. August 04, 2009 at 7:49 pm, Abc said:

    This is good information

    - cheers

    Reply

  26. August 18, 2009 at 5:04 am, e. edwards said:

    Small typo right above the ‘Add New Comment’ box:

    Greater than or equal should be ‘ge’, not ‘gt’.

    Reply

  27. August 28, 2009 at 6:04 am, Anil said:

    thanks …quite helpful information..

    Reply

  28. September 10, 2009 at 5:57 am, Anonymous said:

    to kill notepad we have to but .exe so what if want to kill media player or
    an client server on some pc’s in network ?!!???!

    Reply

  29. September 10, 2009 at 2:37 pm, Anonymous said:

    Thank you, qmchenry!
    Works as expected.

    Reply

  30. December 02, 2009 at 3:19 pm, jon said:

    You say this is for services and it is not. Processes are different from services, look it up

    Reply

  31. January 10, 2010 at 4:27 pm, Menea said:

    It simply does not work [if anyone says 'yes, it works' then simply lies].
    You run it, it says ‘SUCCESS: The process “xxxxx.exe” with PID 1860 has been terminated’ but… process still running. You run second time and again ‘success’ ‘SUCCESS: The process “xxxx.exe” with PID 1860 has been terminated’… and so on.

    Reply

  32. February 12, 2010 at 8:20 pm, Germino said:

    Thank you very much !!

    Reply

  33. March 04, 2010 at 8:10 am, Mechanic said:

    Thank You!
    It’s amazing to know that XP has such built-in command.
    I’ve tried to use Toolhelp32 API to kill processes, but it doesn’t enumerate processes spawned by another users (not current).
    That tool kills processes with image name independent of the user’s context it’s running!
    Thanks!

    Reply

  34. March 05, 2010 at 11:25 am, Anonymous said:

    it works,,,,,,,,,, Thanks…..

    Reply

  35. April 11, 2010 at 10:13 am, Rajesh Naik said:

    I get access denied for process which are started with Administrator privileges. Anyone know how to kill process started with elevated access.

    Reply

  36. April 13, 2010 at 2:23 pm, Anonymous said:

    cool

    Reply

  37. April 22, 2010 at 9:29 am, Anonymous said:

    When not succeeding in stopping use “net stop (service)” instead

    Reply

  38. June 01, 2010 at 3:13 am, Ali said:

    I couldn’t get the taskkill to execute on cmd. Did I miss something?

    Reply

  39. June 23, 2010 at 2:06 am, tung said:

    oip

    Reply

  40. June 25, 2010 at 12:48 pm, Svanstaaden said:

    Ok, but what about processes that don’t terminate in XP although you called the taskkill /f /im PROCESSNAME ??!?!?!? Some process might say : “Access denied” . How are those killed ?! And please don’t tell me it doesn’t work – The shutdown kills everything, wether or not it is “access denied”, so how does the shutdown get it right to kill ALL processes ?!

    Reply

    • June 01, 2012 at 2:53 am, ahaha said:

      > lol at this one :) )

      Reply

  41. June 26, 2010 at 4:39 pm, Jujaja said:

    ХУЙНЯ! БЛЯ ПИЗДЕЦ! НИХУЯ НЕ РАБОТАЕТ! АВТАР ДАЛБАЁБ! СУКА”

    Reply

  42. July 31, 2010 at 10:48 pm, Coldfire Coldfire said:

    Reply

  43. August 03, 2010 at 8:26 am, ABC said:

    thanks… got the solution…

    Reply

  44. August 18, 2010 at 12:37 pm, Greiciunas2010 said:

    Thanks for the help. This one actually save me much time.

    Reply

  45. August 26, 2010 at 2:43 pm, Motogpwade said:

    hi i just did this but the process is still there and it wont die.
    please help?

    Reply

  46. September 03, 2010 at 10:29 am, Abhi said:

    I am really happy with the solutions that are uploaded on the web site. they are awesome and reliable.
    Best Regards, abhi
    http:

    Reply

  47. September 08, 2010 at 9:01 pm, Rob said:

    moral of the story: don’t buy HOME edition when you want to automate

    Reply

  48. September 14, 2010 at 4:55 am, Dawood said:

    tooooo good , Thxxx Bro

    Reply

  49. September 16, 2010 at 12:26 pm, Aa said:

    Thanks, I was looking for it

    Reply

  50. October 09, 2010 at 2:16 pm, Lolmismo said:

    thanks :P

    Reply

  51. October 20, 2010 at 12:38 am, Mokka said:

    But it doesnt the system critical process…. Try killing services.exe

    Reply

  52. October 20, 2010 at 8:08 am, Usha Topagi said:

    Could some one please help me for closing the Outlook window?
    Problem: I have Outlook 2003 running on XP. I have opened many Outlook mail items. By finding window title of the mail item i want to close the window, but not the Outlook process.
    I tried the below code, but it is not working for Outlook windows

    1) C:> taskkill /F /FI “WINDOWTITLE eq Document1 – Message (HTML)” –
    This winow will open when we try to send email from MS Word (File – Send To – Mail Recipient (as attachment))
    2) C:>taskkill /F /FI “WINDOWTITLE eq FW: Secure Email – HLD – Sign-off – Message (HTML)”

    Reply

  53. October 23, 2010 at 10:18 pm, Growing_wearyz said:

    so in theory your trojan may not be so successful on a windows XP Home Edition Computer :P

    Reply

    • December 19, 2010 at 11:41 pm, Bill Gates said:

      it works if you put
      tskill “firefox”

      Reply

      • December 19, 2010 at 11:42 pm, Bill Gates said:

        Works

        Reply

  54. December 02, 2010 at 9:46 pm, ur an idiot said:

    alt F4

    Reply

  55. December 19, 2010 at 11:43 pm, Billgates said:

    yes but it depends on what version of windows you use

    Reply

  56. January 06, 2011 at 8:21 am, Sywa said:

    Here is simple example on taskkill to kill a process using a port 2425:

    > use this to find the associate Process using port 2425

    netstat -ano | find “2425″

    >return :

    TCP 0.0.0.0:2425 0.0.0.0:0 LISTENING 3140

    >Kill the process using port 2425

    taskkill /PID 3140

    where 3140 is the application PID using port 2425

    Reply

  57. January 06, 2011 at 12:57 pm, Fredgimz said:

    Don’t know if it is an issue for all Windows, but i found on a windows 2003 server that the operator “gt” fails on my filter upon CPUTIME. (While this works correctly for tasklist.exe) my workaround was to use “ge” instead.
    ie:
    tasklist /FI “CPUTIME gt 00:30:00″ => success
    taskkil /FI “CPUTIME gt 00:30:00″ => fails (no match found)
    taskkill /FI “CPUTIME ge 00:30:00″ => success

    Reply

    • January 07, 2011 at 3:57 pm, Fredgimz said:

      Well, finally this was just a lucky strike, i cannot reproduce this..
      The problem seems to concern the time string, results are very very inconsistent, with any combination of gt ge lt le.
      It even doesn’t recognize my filter if i use 00:00:51 so 51s or above, while “51:51:50″ and even “00:69:00″ are fine !!!
      It looks like the getting of time or something is completely fucked up…

      Reply

    • January 12, 2011 at 9:40 pm, Dep_7 said:

      Yea, that on gt in the filters is a typo. It should be ge.

      Reply

  58. January 07, 2011 at 7:04 am, nike outlet store said:

    You can couple it with the tasklist /SVC command to see the process id of the process and then use taskkill on it that way you can be sure of the process you are terminating and can also spot malwares.

    Reply

  59. January 10, 2011 at 1:03 pm, Carlos_go said:

    I ve got a problem with tasklist. It runs in an Windows Server 2003 but doesnt run in Windows XP Profesional SP3. When my app hungs, the Task Manager shows me that is not responding but if I check it with the tasklist command, it shows me that is running,

    I dont understand, because I check the services options between both operating systems and change them to be the same.

    Thank you so much in advance!!

    Reply

  60. January 13, 2011 at 6:08 pm, Sajmmon said:

    Great post.

    I used it to kill hanged Excel.exe when working over RemoteDesktop. Is there any way to access TaskManager over the RemoteDesktop?

    Regards

    Reply

    • January 18, 2011 at 7:28 am, Edmon Daniel said:

      right click taskbar and Select “Start Task Manager”

      Reply

  61. May 07, 2011 at 11:58 am, Fggdfg said:

    werr

    Reply

  62. August 08, 2011 at 7:23 am, rif4fun said:

    your site is very helpfull
    thanx
    i wanna copy a part of your site to my blog :)
    http://ragam-komputer.blogspot.com

    Reply

  63. August 15, 2011 at 10:58 pm, Azazelahh said:

    This fix just made my life sublime. THNX!!!!

    Reply

  64. October 27, 2011 at 8:52 pm, PasserBy said:

    Interesting how many strange comments there are on this post. Nice concise article though. Thanks.

    Reply

  65. November 09, 2011 at 3:22 am, My fast PC said:

    It’s yet another way shut down your processes. I personally don’t see any difficulties running the task manager panel. You all have them outlined and don’t need to remember the process name. Still, nice article.

    Reply

  66. November 17, 2011 at 2:26 am, jo said:

    really helpful post to me, as my env was not showing Task manager during critical hours and these commands helped to fix the problems. Thanks.

    Reply

  67. January 14, 2012 at 11:43 pm, sid said:

    thanx it realy work…. thanx a lot for solve my prob…..

    Reply

  68. February 17, 2012 at 4:11 pm, tetricacy said:

    Thanks! I used this today when my work PC got hung up while I was working from home via RDP. When this happens, I can’t access task manager as usual (it just opens to a blank box) but, in order to log off or restart, I need to kill a certain process related to the adapter for dual monitors. Until now, I had to depend on calling someone in the office to shut off and turn on the PC for me. Obviously, that only works during business hours! Appreciate the help.

    Reply

  69. March 09, 2012 at 8:43 am, Kiran said:

    Thanks a lot for this post…..

    Reply

  70. April 10, 2012 at 1:48 pm, Venkatesh G said:

    Thank you very much, this helped us a lot!

    Reply

  71. April 12, 2012 at 4:26 am, Mukul Vashist said:

    Put these commands in cmd: taskkill /PID number /f

    Reply

  72. April 12, 2012 at 4:32 am, Mukul Vashist said:

    GO TO RUN>cmd> taskkill /PID number /f
    This will kill the processes, as per the PID number given.

    Reply

  73. May 16, 2012 at 2:35 pm, Test said:

    Thanks!! works like a charm :)

    Reply

  74. May 29, 2012 at 2:27 pm, aaa said:

    Is there any way to kill any idle process, for e.g. a running notepad process is idle for last half an hour, so is there any way taskkill can kill the process , if its idle for more than 30 minutes.

    Reply

  75. June 25, 2012 at 10:43 am, SHIABOOKS.IR said:

    HI

    VERY GOOD

    Reply

  76. October 08, 2012 at 2:58 pm, Samoun said:

    I want to use taskkill to kill the process which is using cpu up to 70% please help me.

    Reply

  77. October 17, 2012 at 6:02 am, Marsshallsmith said:

    This is what i was looking for… it great workin with batch in batch files…

    Reply

  78. October 21, 2012 at 2:48 am, Sergio said:

    This article was very usefull!
    Many thanks!

    Reply

  79. January 10, 2013 at 4:28 pm, JeffH said:

    Tried this. It did not kill the process, even though the command prompt returned the message that it HAD terminated the process.

    Reply

  80. February 10, 2013 at 11:47 am, Rehan said:

    What if access is denied message is displayed?

    I am actually unable to close a program using task manager, so I switched to cmd but access is denied message is being displayed. What should I do. Please…

    Reply

  81. February 10, 2013 at 11:48 am, Rehan said:

    I’m commenting again because I forgot to check “Notify me of follow-up comments by email.”

    Reply

  82. October 11, 2013 at 7:42 am, Reeju said:

    Thank You Quinn for sharing these details. It helped me to solve my problem in few mins !!!

    Reply

  83. January 27, 2014 at 7:17 pm, DylanDesign said:

    The /F needs to come AFTER the process name, not before it as is suggested on this page.

    E.g.
    TASKKILL /IM PROCESSNAME.EXE /F

    Reply

Leave a Reply