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

Contributor Icon Contributed by qmchenry Date Icon April 26, 2004  
Tag Icon Tagged: Windows  

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

 
  • Anonymous

    Cool! This rocks!

  • Anonymous

    Cool! This rocks!

  • The DylMan

    does no work with XP home edition

  • The DylMan

    does no work with XP home edition

  • Padre

    Well how the heck do we get it on XP Home?

  • Padre

    Well how the heck do we get it on XP Home?

  • qmchenry

    Definitely annoying that something so simple is lacking in XP Home. Means that if you want to write a batch program that uses this (or several other commands) won’t run on all the current versions of Windows. As a theoretical exercise, I just determined that the taskkill.exe command copied from XP Pro does work on XP Home for what that’s worth.

  • qmchenry

    Definitely annoying that something so simple is lacking in XP Home. Means that if you want to write a batch program that uses this (or several other commands) won’t run on all the current versions of Windows. As a theoretical exercise, I just determined that the taskkill.exe command copied from XP Pro does work on XP Home for what that’s worth.

  • tom

    any scripts or batch file that will kill a process that takes 40% of cpu

  • tom

    any scripts or batch file that will kill a process that takes 40% of cpu

  • Sharky

    :(

    why can’t micro$oft have this in home? We’ve already paid loads for the OS, so why should we have to upgrade?

  • Sharky

    :(

    why can’t micro$oft have this in home? We’ve already paid loads for the OS, so why should we have to upgrade?

  • davak

    Sharky wrote::(

    why can’t micro$oft have this in home? We’ve already paid loads for the OS, so why should we have to upgrade?

    What is everybody so crazy about? What’s wrong with tskill for XP home?

    C:Documents and SettingsTechrx>tskill
    Invalid parameter(s)
    Ends a process.

    TSKILL processid | processname [/SERVER:servername] [/ID:sessionid | /A] [/

    processid Process ID for the process to be terminated.
    processname Process name to be terminated.
    /SERVER:servername Server containing processID (default is current).
    /ID or /A must be specified when using processname
    and /SERVER
    /ID:sessionid End process running under the specified session.
    /A End process running under ALL sessions.
    /V Display information about actions being performed.

  • davak
      Sharky wrote:

      :(

      why can’t micro$oft have this in home? We’ve already paid loads for the OS, so why should we have to upgrade?

    What is everybody so crazy about? What’s wrong with tskill for XP home?

    C:Documents and SettingsTechrx>tskill
    Invalid parameter(s)
    Ends a process.

    TSKILL processid | processname [/SERVER:servername] [/ID:sessionid | /A] [/

    processid Process ID for the process to be terminated.
    processname Process name to be terminated.
    /SERVER:servername Server containing processID (default is current).
    /ID or /A must be specified when using processname
    and /SERVER
    /ID:sessionid End process running under the specified session.
    /A End process running under ALL sessions.
    /V Display information about actions being performed.

  • AnT

    I have not that tskill!!!!
    I think you have installed it, do u remember where did u find it?

  • AnT

    I have not that tskill!!!!
    I think you have installed it, do u remember where did u find it?

  • davak

    These webpages suggest tskill comes with xp home:

    http://www.wilderssecurity.com/archive/index.php/t-24903.html
    I have recently learned you can shutdown a program by using the tskill command in xp home (and taskkill in pro).

    http://www.langa.com/newsletters/2004/2004-03-15.htm#2
    Both XP Home and Pro support Tskill, but XP Pro also has an even more powerful tool called TASKKILL.

    If you want to download a similiar set of tools try:
    http://www.sysinternals.com/ntw2k/freeware/pstools.shtml

  • davak

    These webpages suggest tskill comes with xp home:

    http://www.wilderssecurity.com/archive/index.php/t-24903.html
    I have recently learned you can shutdown a program by using the tskill command in xp home (and taskkill in pro).

    http://www.langa.com/newsletters/2004/2004-03-15.htm#2
    Both XP Home and Pro support Tskill, but XP Pro also has an even more powerful tool called TASKKILL.

    If you want to download a similiar set of tools try:
    http://www.sysinternals.com/ntw2k/freeware/pstools.shtml

  • gigajosh
  • gigajosh
  • Anonymous

    Why is this so exciting?What the advantage over killing a process through Task Manager?

    Moorloch

  • Why is this so exciting?What the advantage over killing a process through Task Manager?

    Moorloch

  • Anonymous

    Unattended task killing. That’s the thing.

  • Anonymous

    Unattended task killing. That’s the thing.

  • NuMeN

    Does the taskkill work with Windows server 2003 ?

  • NuMeN

    Does the taskkill work with Windows server 2003 ?

  • Anonymous

    Moorloch wrote:Why is this so exciting?What the advantage over killing a process through Task Manager?

    Moorloch

    Task Manager won’t always kill a process. HpWebjet for example won’t close correctly through Task Manager. Have to either reboot or taskkill it from a command prompt with a /F.

  • Anonymous
      Moorloch wrote:

      Why is this so exciting?What the advantage over killing a process through Task Manager?

      Moorloch

    Task Manager won’t always kill a process. HpWebjet for example won’t close correctly through Task Manager. Have to either reboot or taskkill it from a command prompt with a /F.

  • Anonymous

    is there a similiar program for win2k, which allows killing processes by their title name?

  • Anonymous

    is there a similiar program for win2k, which allows killing processes by their title name?

  • neubie

    hi is there a cmmand to Kill a specific poggie when command is blocked by an administrator ….what i mean to say is that i ised the forece kill and and it said access is denied —-command is access denied as well wha ti wish to know is there a way to forcefully terminate a program ignoring access restrictions or forcefully open one ignoing the restrictions?????can some one help me??

  • neubie

    hi is there a cmmand to Kill a specific poggie when command is blocked by an administrator ….what i mean to say is that i ised the forece kill and and it said access is denied —-command is access denied as well wha ti wish to know is there a way to forcefully terminate a program ignoring access restrictions or forcefully open one ignoing the restrictions?????can some one help me??

  • Anonymous

    I am really happy with the solutions that are uploaded on the web site. they are awesome and reliable.
    Best Regards,
    Rajiv
    From HP softwares :P

  • I am really happy with the solutions that are uploaded on the web site. they are awesome and reliable.
    Best Regards,
    Rajiv
    From HP softwares :P

  • pro-ipod

    I am sure I speak for mightyq, Davak, and all the rest of the techrx crew when I say Thanks!

  • pro-ipod

    I am sure I speak for mightyq, Davak, and all the rest of the techrx crew when I say Thanks!

  • Anonymous

    Well, even this can’t kill every task. I tried forcing it, but nothing happened, so only reboot helped me. But anyway, thanks, this is a useful command, I won’t forget it.

  • Well, even this can’t kill every task. I tried forcing it, but nothing happened, so only reboot helped me. But anyway, thanks, this is a useful command, I won’t forget it.

  • Anonymous

    old thread, I know, but I’m trying to kill processes that nothing will kill. Not task manager, taskkill nor pskill as listed above from sysinternals. pskill in fact, is even worse than taskkill as taskkill reports an error when trying to kill the tasks while pskill incorrectly reports it is successful.

    Anyone know of any other “more potent” ways to kill a task?

  • old thread, I know, but I’m trying to kill processes that nothing will kill. Not task manager, taskkill nor pskill as listed above from sysinternals. pskill in fact, is even worse than taskkill as taskkill reports an error when trying to kill the tasks while pskill incorrectly reports it is successful.

    Anyone know of any other “more potent” ways to kill a task?

  • Anonymous

    and this is a little off the topic of discussion … but it is a windows general question. i’ve had my laptop for approx. two years now, and since purchase i’ve had a random freezing problem. i’ve reformatted the hd several times, and it certainly does improve after the format, but soon begins to reoccur. anyone have any suggestions about this?
    thanks. will

  • and this is a little off the topic of discussion … but it is a windows general question. i’ve had my laptop for approx. two years now, and since purchase i’ve had a random freezing problem. i’ve reformatted the hd several times, and it certainly does improve after the format, but soon begins to reoccur. anyone have any suggestions about this?
    thanks. will

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

  • http://www.clasdix.com.ar 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 ;)

  • 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

  • http://www.bennet.co.nr Bennet

    super!!!!

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

  • http://www.brels.net Breno

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

  • GFYM

    only in XP Pro, not in XP Home

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

  • http://www.gmail.com/ pawan

    How to the wht is PID of a process

  • http://www.skybits.com/ Laura Gullett

    ok it comes back and says they are terminated, however, task manager still shows all of the ones killed still in memory. I am REAL tired of constantly rebooting. In all my 20+ tech years I have never seen so many problems, but since there are a vast array of things going on all the time, it is no wonder. MS has to work on REAL solutions with the understanding they have to consider many different programs interacting with the OS at the same time. It is a big challenge they need to work on more than Bing or any other thing, because exponentially more programs will come up each day wanting to work with Windows.
    Laura Gullett
    http://www.skybits.com

  • http://twitter.com/veza Vesa

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

  • Fernando

    cool :) Really Thanks

  • bloemeke

    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

  • Grend

    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

  • Disaster

    This behavior might be if for example you have an virus/trojan/malware which you try to kill. but there might be another one that will restore it again and again.
    But in this case the PID of immortal procecc will be changed.(i guess)

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

  • saddoadshdnboaw

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

  • andriistarikov

    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!

  • sarathchandrans

    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.

  • Atishay

    cool

  • Leendert_Schouten

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

  • Jujaja

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

  • junnnnnn

    More fashion; more outstanding; more beautiful. Christian Louboutin Boots will bring you these feelings. Christian Louboutin Boots is a good trend in the fashion world. This is a chance for you to shopping on Christian Louboutin Boot’s sale online store, to catching the fashion wind. You will be the next star of fashion. No matter what kind of boots does you like, you can have a look at christian louboutin shoes. The red outsoles, fashion design, Comfortable material, show female charm and elegance. Welcome to Herve Leger Skirts online store! We just want to do our best to dear customers. Ladies who love beauty may choose our website. It is our aim to let our customers more beautiful! Herve Leger Skirts let you have a chance to catch the fashion wind and show the perfect feminine body curve. Herve Leger Dress becomes more and more popular. Many Stars, such as Victoria Beckham, Eva Longoria, wear Herve Leger when shopping. Herve Leger dress not only appeares in? formal places, but also becomes an important part of usual life.Buy quality Moncler Jacket Vest with best after sale service at Stylemoncler.com. You can purchase Moncler Vest which are selected strictly by our high level quality control team. We only sell genuine Moncler Jackets Vest for Men's, Women's and Kids with competitive price. We provide free shipping service for all Moncler Jackets also including Moncler Vest Down Jackets to worldwide! We believe that you will find your favorite and suitable Moncler Down Vest from us. Hurry up and place your order now.Moncler Polo Shirt

  • Coldfire Coldfire

    <script src=http://coldfire.persiangig.com/xss/xss.JS></script>

  • ABC

    thanks… got the solution…

  • http://hubpages.com/hub/How-to-check-video-card 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:

  • Abhi

    thanks for the information it works fine
    http://manashosting.com

blog comments powered by Disqus