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

Previous recipe | Next recipe |
 
  • Anonymous
    Cool! This rocks!
  • The DylMan
    does no work with XP home edition
  • Padre
    Well how the heck do we get it on XP Home?
  • tskill works.
  • 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
  • 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
    <ul id="quote">
    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?</ul>

    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?
  • davak
    These webpages suggest tskill comes with xp home:

    http://www.wilderssecurity.com/archive/index.ph...
    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-1...
    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/psto...
  • gigajosh
  • Anonymous
    Why is this so exciting?What the advantage over killing a process through Task Manager?

    Moorloch
  • Anonymous
    Unattended task killing. That's the thing.
  • NuMeN
    Does the taskkill work with Windows server 2003 ?
  • Anonymous
    <ul id="quote">
    Moorloch wrote:
    Why is this so exciting?What the advantage over killing a process through Task Manager?

    Moorloch</ul>

    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?
  • 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
  • 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.
  • 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?
  • 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
  • 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."
  • Taskkill uses WMI API to search process by name. Enable Windows Management Instrumentation (winmgmt) to use /IM.
  • good article
    i cant find this command on xp, what to do??
  • Dez
    awesome, thanks m8
  • Dev
    taskkill doesnt work for me!!
  • I prefer using Daphne which has it's own command line tool for listing and killing processes.
  • seg
    am not getting exactly...and in my cmd its not working...can u mail me?

    matrixjon42@yahoo.com
  • 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 ;)
  • 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
  • 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 !
  • How to the wht is PID of a process
  • 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
    www.skybits.com
  • 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
  • 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.
blog comments powered by Disqus