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.

  • coder

    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.

  • Kevski

    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.”

    • http://www.brels.net Breno

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

  • http://www.theway2invest.com farouk

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

  • Dez

    awesome, thanks m8

  • Dev

    taskkill doesnt work for me!!

  • Hern

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

  • http://www.tech-recipes.com/rx/446/xp_kill_windows_process_command_line_taskkill/ seg

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

    matrixjon42@yahoo.com

  • http://freewaresoft.blogspot.com deen

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

  • ADSF

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

  • Anonymous

    tskill works.

  • Dan

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

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

    Dan

  • aathisankar

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

  • Vivek

    thanks ,really i got what expected

  • swapnil

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

  • Nikhil Bhatt

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

    Thanks once again !!!!

    • Rama

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

  • GFYM

    only in XP Pro, not in XP Home

    • Mike

      Yeah, only XP Pro! Another dumb solution!

      It works in Windows 7 Premium, though.

  • fgf

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

  • kelvin

    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.

  • Tichomir Mitkov

    cool, man !

  • pawan

    How to the wht is PID of a process

  • http://twitter.com/veza Vesa

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

  • Fernando

    cool :) Really Thanks

    • Anonymous

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

  • morph

    @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

  • Anonymous

    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?

  • Abc

    This is good information

    - cheers

  • e. edwards

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

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

  • Anil

    thanks …quite helpful information..

  • Anonymous

    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 ?!!???!

  • Anonymous

    Thank you, qmchenry!
    Works as expected.

  • jon

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

  • Menea

    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.

  • Germino

    Thank you very much !!

  • Mechanic

    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!

  • Anonymous

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

  • Rajesh Naik

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

  • Anonymous

    cool

  • Anonymous

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

  • http://ezine.pk Ali

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

  • http://profiles.yahoo.com/u/SBBFI7MTGSCGRQ4ZHM67MUK2XM tung

    oip

  • Svanstaaden

    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 ?!

    • ahaha

      > lol at this one :))

  • Jujaja

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

  • Coldfire Coldfire
  • ABC

    thanks… got the solution…

  • Greiciunas2010

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

  • Motogpwade

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

  • Abhi

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

  • Rob

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

  • Dawood

    tooooo good , Thxxx Bro

  • Aa

    Thanks, I was looking for it

  • Lolmismo

    thanks :P

  • Mokka

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

  • Usha Topagi

    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)”

  • Growing_wearyz

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

    • Bill Gates

      it works if you put
      tskill “firefox”

      • Bill Gates

        Works

  • ur an idiot

    alt F4

  • Billgates

    yes but it depends on what version of windows you use

  • Sywa

    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

  • Fredgimz

    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

    • Fredgimz

      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…

    • Dep_7

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

  • http://www.nikestoreoutlet.com nike outlet store

    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.

  • Carlos_go

    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!!

  • http://www.ipipan.eu/~sch/ Sajmmon

    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

    • Edmon Daniel

      right click taskbar and Select “Start Task Manager”

  • Fggdfg

    werr

  • rif4fun

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

  • Azazelahh

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

  • PasserBy

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

  • http://computerdiagnostics4u.com My fast PC

    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.

  • http://no jo

    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.

  • sid

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

  • tetricacy

    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.

  • http://www.oztek.in/ Kiran

    Thanks a lot for this post…..

  • Venkatesh G

    Thank you very much, this helped us a lot!

  • Mukul Vashist

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

  • Mukul Vashist

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

  • Test

    Thanks!! works like a charm :)

  • aaa

    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.

  • SHIABOOKS.IR

    HI

    VERY GOOD

  • Samoun

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

  • Marsshallsmith

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

  • Sergio

    This article was very usefull!
    Many thanks!

  • JeffH

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

  • Rehan

    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…

  • Rehan

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

  • Reeju

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

  • DylanDesign

    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

  • Ch Saeed