Using Command Prompt To View/Kill Process
Yesterday, i was using Linux and it reminded me of "ps" and "kill" commands to view and kill processes.This article is to show you how to do it in Windows.
Windows user are quiet familiar with Task Manager which you can get by pressing ctrl + alt + del buttons simultaneously. When you press the alt + ctrl + del key to open the Task Manager and try to kill the 'memory eating processes' and the ones which are 'not responding'. Well, sometimes the Task Manager may not open or it may be blocked by administrator, in such cases you can use the command prompt(cmd).
To open cmd, click on start, click on run, type cmd and hit enter.
Firstly, you need to view the process id also called the process number. You can view this by opening Task Manager, then click on Processes tab.
After that, click on view and then click on Select Columns, select PID, memory usage, CPU usage and Username.
There are three ways:-
1. Tasklist : Tasklist is used to see how much memory and CPU time running processes are using, DLL files that they rely on and other information. Thus it can be a very useful tool.
Processes info: Write tasklist on the command prompt and hit enter, you will see the following informations by default:
Image Name, PID, Session Name, Session#, Mem Usage
All the processes that are on going and other information is easily seen.
Processes detailed info: To see additional information like, Status, User Name, CPU Time, Window Title
use ----> tasklist /v
Services and Processes information: To get a table relating Image Name, PID, and Services, This also makes it easy to know the relationship between a process and the services that are running on a system,
use ----> tasklist /svc
dlls and processes info: To find which dll's are used by each process,
use ----> tasklist /m
Filtering processes: Processes can be filtered using ImageName, PID, MemUsage, Status, Username and WindowTitle. For Example,
To find processes that are not responding,
use ----> tasklist /fi "status eq not responding"
To list the processes eating up more than 10mb,
use ----> tasklist /fi "memusage gt 10000"
To get more syntax of the command use tasklist /? and see the help section or refer to Microsoft’s documentation.
Note: Tasklist is a part of Windows XP Professional, it does not come with the Home edition. If you have the Home version of XP can download this file and can put it in the system path to work with it.
2. Tskill : This command is used to end a process, using the name of its PID (Process Identifier).
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.
To get more syntax of the command use tskill /? and see the help section or refer to Microsoft’s documentation.
Note: Tskill is a part of both Windows XP Professional and the Home edition. So, it will work for Home users.
3. Taskkill : This is very much similar to Tskill. This command is used to end a process. It provides more options compared to Tskill. Apart from specifying the PID or the image name of the process to kill, we can also use certain filters to kill the matching processes.
Kill with name: To kill a process with the given Image name, use ----> taskill /IM imagename
example: taskkill /im notepad.exe /f (forces notepad to be killed.)
Kill with PID : To kill a process with the given processid, use ----> taskill /PID processid
Filtering Taskkill: The processes can be filtered using ImageName, PID, MemUsage, CPUTime, Session, Status, Username, WindowTitle, Services or Modules (dll).
For Example,
To forcefully shut down all the processes that are not responding,
use ----> taskkill /f /fi "status eq not responding"
To close down all programs using more than 10mb,
use ----> taskkill /f /fi "memusage gt 10000"
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.
Enjoy killing your processes.... keep reading and have fun :)
No comments:
Post a Comment