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
-
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.
hehe.. it helped me in my new DotA.bat file
this one was good 🙂
will this help me find viruses if i have any?
thanks, very helpful.
Nice to see the requested answer.
hi
Hey great one man… just helped us like n e thing.. keep it up.,. thanks
San
very good man!!! keep it up…
good article :).
hmm nice i will create a .net application for this killing of process
Lol…. writing it in vb is very simple…
u need to use
Shell(“TaskKill [Options] Processname”)
tnx a lot.. more power..
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! 😉
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
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…
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.
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.
John,
While in a remote session, CTRL+ALT+END will also get you to the remote Task Manager…
here
why do you people all seem stupid and fake?
Cause we are.
You think that’s air you are breathing?
i double clicked the virus file. it began to run and task manager is not opening. how to stop the process through command prompt
Thanks man Its rally help for killing processes
Thanks a lot.
hi,
need a solution to list all the processes which are in fact viruses.
thanks in advance.
Aravind
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”.
thanks dude it really helped but it says access denied wen i tried closing xtrap
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.
thanx !
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.
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.
Extremely useful post. Best regards.
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
Superb!
Thank you
Awesome. I got my task manager itself hanging and i used the follwing command to kill it 🙂
taskkill /im taskmgr.exe /f
Thanks yaar, I search it for long time and i got it very easily from your site….
thanks again…
Thanks a lot
I want it, but no one can able to answer that
that got very easily from your site.
so thanks again.
is somehow possible to find out location of file on hard drive of process which I know the name?