Command Prompt - Dealing with Tasks
Dan Wheeler
Posted on June 5, 2023
We can use commands to find out what tasks are running on a machine. Also note, all of these can be run using PSEXEC to a remote machine (some may require connection via PSEXEC using your admin account also).
See a list of tasks
First, open Command Prompt and type:
tasklist
This will return results in a crude looking table showing you the Image Name (filename of the application), it's PID (or ID Number), the session name, number and how much memory it is currently using. Only the image name and PID are relevant here.
Export task list to text file
This will dump a huge list of tasks that the computer is currently running (the same list you'd find in Task Manager). The formatting though leaves something to be desired, so you may wish to dump the results to a text file like so:
tasklist > c:\tasklist.txt
Find a specific task
Next up, we can search for individual tasks by using the below, remember seeing the Image Name earlier? This example will return all found results for Outlook:
tasklist /fi "imagename eq outlook.exe"
You can also do a partial search using something like:
tasklist /v | find "Note"
Add a /i at the end to make it case-insensitive too!
Kill a task
Also remember earlier we saw that the tasklist results produced a PID for each task... we can kill a task by using the following:
taskkill /F /PID ####
If we replaced the #### with the actual PID number of the task we want to kill, it will work. Although, be careful as it will force close the application without saving anything or backing it up.
Useful to Know!
All the below can be run through PSEXEC too for dealing with tasks on a remote machine.
Posted on June 5, 2023
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.