Wednesday, 25 June 2008

Querying the Task Manager Quickly

Doing Cntrl-Alt-Del and running Task Manager is a time-consuming process. Instead, the tasklist command can be used to get a list of running tasks.

For example, if you want to get a list of tasks taking up more than 50Megs in memory then use the "FI" (filter) parameter with tasklist as follows:

tasklist /FI "MEMUSAGE gt 50000"

An easy mistake to make is to type ">" rather than "gt". This will not work. It will give you an error: "ERROR: The search filter cannot be recognised".

On my system this returns just one process:

Image Name PID Session Name Session# Mem Usage
firefox.exe 3120 Console 0 70,116 K

There don't appear to be any built-in sorting functions based on memory or CPU usage, but this is easy to program by parsing the output of tasklist.exe in Python, Perl or some other scripting language. You will need to use tasklist /V (for verbose mode) to see CPU usage information.

No comments: