WindowsXP: Using the Command prompt to see and kill processes

To look at the active version of this post Visit  Techmonks.net

If you are a WindowsXP user then you must be already familiar with the life-saving graphical tool called “Task Manager” on Windows. Whenever the PC starts hanging and the processes start eating up a lot of memory (Sadly most of the time its Firefox for me), we press the alt+ctr+del key to bring up the the “Task Manager” and try to kill the memory eating processes and the ones which are “not responding”. Well, you should also know that this can be done efficiently from the command prompt as well.
As my project work requires writing and running codes, I generally have at least one Windows command prompt open. If this is the case with you then it is much faster to manage your windows processes from command prompt than to open up the Task Manager, just like we do on Linux using “ps” and “kill” command. Get to know the following commands and you can easily use the command prompt to see and kill processes.
1. Tasklist : This command is similar to “ps” command on Linux and is used to see the details of the programs and processes that are running in Windows. Tasklist can be applied to see how much memory and CPU time running processes are using, what DLL files they rely on, and other information. Thus it can be a very useful troubleshooting tool.
  • Processes info: When you enter tasklist on the command prompt, you can see the following informations by default. Image Name, PID, Session Name, Session#, Mem Usage
  • Processes detailed info: Additional info like, Status, User Name, CPU Time, Window Title can be displayed using tasklist /v
  • Services and Processes info: Use tasklist /svc to get a table relating Image Name, PID, and Services, very useful to know the relationship between a process and the services that are running on a system.
  • dlls and Processes info: Tasks and Use tasklist /m to find which DLLs are used by each process.
  • Filtering processes: Processes can be filtered using ImageName, PID, MemUsage, Status, Username and WindowTitle. For Example,
    • Use the following command to to find processes that are not responding.
      • tasklist /fi "status eq not responding"
    • Use the folliwing to list the processes eating up more than 10MB.
      • tasklist /fi "memusage gt 10000"
  • More Info: To get more info on advanced syntax of the command use tasklist /? or refer to Microsoft’s documentation.
(NOTE: Although Tasklist is a part of Windows XP Professional, it does not come with the Home edition. Those with the Home version of XP can download this file and can put it in the system path.)
2. Tskill : This command is used to end a process, using its name of its PID.
  • Kill with name: Use tskill processname to kill a process with name processname. For example:
    • tskill winword (closes all the Microsoft documents that you have open)
  • Kill with PID : Similarly use tskill processid to kill a process with PID processid. Tasklist can be used to find the PID of a process.
  • More Info: To get more info on advanced syntax of the command use tskill /? or refer to Microsoft’s documentation.
(NOTE: Tskill is a part of both Windows XP Professional and the Home edition.)
3. Taskkill : Similar to Tskill, this command is also used to end a process but it provides us more options in doing so. Apart from specifying the PID or the image name of the process to kill, we can also use ceratin filters to kill the matching processes as explained below.
  • Kill with name: Use taskill /IM imagename to kill a process with the given Image name. For example:
    • taskkill /im notepad.exe /f (forces notepad to be killed.)
  • Kill with PID : Use taskill /PID processid to kill a process with the given processid.
  • Filtering Taskkill: Processes to be killed can be filtered using ImageName, PID, MemUsage, CPUTime, Session, Status, Username, WindowTitle, Services or Modules (dll). For Example,
    • Use the following command to forcefully shut down all the processes that are not responding.
      • taskkill /f /fi "status eq not responding"
    • Use the folliwing to close down all programs using more than 10 MB..
      • taskkill /f /fi "memusage gt 10000"
  • More Info: To get more info on advanced syntax of the command use taskkill /? or refer to Microsoft’s documentation.
(NOTE: Taskkill is only a part of Windows XP Professional.)
Go on, show the power of your commands to the processes. Happy killing them. 😉
(Extra Note (Added for my own safety) : I am not responsible if anything goes wrong, while trying out the commands given here.)

38 comments so far

  1. DarK on

    hehe.. it helped me in my new DotA.bat file

  2. Prasoon on

    this one was good 🙂

  3. Rower93 on

    will this help me find viruses if i have any?

  4. hyperwired on

    thanks, very helpful.

  5. DNMurali on

    Nice to see the requested answer.

  6. 1sajith1 on

    hi

  7. Anoop on

    Hey great one man… just helped us like n e thing.. keep it up.,. thanks

    San

  8. janus on

    very good man!!! keep it up…

  9. yogi on

    good article :).

  10. amrishwa bihari on

    hmm nice i will create a .net application for this killing of process

  11. Shwet on

    Lol…. writing it in vb is very simple…
    u need to use

    Shell(“TaskKill [Options] Processname”)

  12. Rex on

    tnx a lot.. more power..

  13. Alireza on

    thanks man! it helped me kill a virus that used to hide itself in the task manager, it seems that they cant hide themselves in cmd! 😉

  14. Sarav on

    How can i use CPUTIME in taskkill.
    Can anyone please give me an example.
    Is it possible to kill a task according to the system time?
    Thanks

  15. shajid on

    Hi,

    This helpful for me…. Good… But i need some more help….. that…. If we give PID i need some CPU utilization in percentage as it is in taskManager….
    If i can get atleast CPU memory from dos prompt, that will be helpful for me…..

    My mailID is: shajid4u@gmail.com

    Thanks in Advance…

  16. Renjith on

    Hello
    Thanks a lot
    Really Hats Off. I was struggling a lot from past two months with firefox hang problem . task manager was not there since i am using citrix.

  17. John on

    Thanks! I had an interesting scenario where these instructions helped alot. On my XP workstation in San Francisco, OUTLOOK.EXE couldn’t be closed. Problem was: I was in New Hampshire on an XP laptop, with a Remote Connection (through a VPN) from the laptop to the workstation. While viewing my remote workstation, I tried using Ctrl-Alt-Del to bring up Task Manager, but … it was showing me the processes/tasks on my local laptop. A Google search got me to your page. As instructed, I opened a DOS box on the workstation, used the tasklist command to find the pid for OUTLOOK, then tskill . Problem solved. Many thanks.

  18. MikeA on

    John,

    While in a remote session, CTRL+ALT+END will also get you to the remote Task Manager…

  19. Jim w on

    here

  20. John on

    why do you people all seem stupid and fake?

  21. Fr0z3n on

    Cause we are.

    You think that’s air you are breathing?

  22. Abbas on

    i double clicked the virus file. it began to run and task manager is not opening. how to stop the process through command prompt

  23. ss on

    Thanks man Its rally help for killing processes

  24. phoephoe9 on

    Thanks a lot.

  25. aravind on

    hi,
    need a solution to list all the processes which are in fact viruses.

    thanks in advance.
    Aravind

  26. wow on

    for all of you using remote computers and not knowing how to get to the task manager… wow. ctrl + alt + end *or* right click on the task bar -> task manager. and for everyone who think this helped them “kill a virus”, you still have them. I don’t even know what to say to ‘aravind’ other than “wow I can’t believe anyone is that stupid”.

  27. lafftar on

    thanks dude it really helped but it says access denied wen i tried closing xtrap

  28. Prabhu on

    Awesome. Some times the taskmanager will not be opening when the system hangs. I usually try for some time and then i reboot the machince. This really helps me.

  29. حسین on

    thanx !

  30. mike on

    this is so amazing. thanks. Our company pc disabled the taskmanager feature and the only way to kill the task is by using command. thanks for this info.

  31. alberto on

    Thanks man for the info. I was looking for a way to display the list of processes using psexec (from pstools) when pslist couldn’t connect to the remote pc.

  32. Walter G on

    Extremely useful post. Best regards.

  33. Flats on

    This almost got me helped me get rid of a viewing process that school uses to monitor your pc… The only problem is, that when i force kill the process, it will tell me : ‘Access denied’… I hope anyone can tell me how to shutdown administator protected programs…
    Thanks in advance

  34. BBDom on

    Superb!
    Thank you

  35. Selva on

    Awesome. I got my task manager itself hanging and i used the follwing command to kill it 🙂

    taskkill /im taskmgr.exe /f

  36. HK the champion on

    Thanks yaar, I search it for long time and i got it very easily from your site….
    thanks again…

  37. HK the champion on

    Thanks a lot
    I want it, but no one can able to answer that
    that got very easily from your site.
    so thanks again.

  38. Alex on

    is somehow possible to find out location of file on hard drive of process which I know the name?


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: