Friday, August 21, 2009

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 titleeq: equals ne: not equal
gt: greater than lt: less than
gt: greater than or equal le: less than or equal

Share this

3 Responses to "XP: kill a Windows process from the command line with taskkill"

  1. Give me a batch file

    ReplyDelete
  2. please create amd update batch file

    ReplyDelete
  3. I'm the sort of hombre who enjoys to seek recent stuff. Presently I'm manufacturing my hold photovoltaic panels. I'm making it all by myself without the assistance of my staff. I'm utilizing the internet as the only path to acheive that. I came across a truly awesome site that explains how to build photovoltaic panels and so on. The site explains all the steps required to constructing solar panels.

    I'm not sure about how precise the data given there is. If some guys over here who have xp with these works can have a peak and give your feedback in the site it will be awesome and I would extremely treasure it, cause I extremely lav [URL=http://solar-panel-construction.com/diy-solar-panel-construction-is-it-really-possible]solar panel construction[/URL].

    Tnx for reading this. U people rock.

    ReplyDelete