The CMD is a very powerful tool, it gives you the ability to automate tasks or get information you can later manipulate to your needs.
In this post I explained how to kill a process (locally or remotely)and now I want to take it one step further and explain how to track the processes I need to kill.
The tasklist.exe is one of the command line tools that lists all the processes running on a windows machine (just like the GUI task manager) and outputs the information as a list, in a format you choose. It can be used later in a script.
This command can be used to list the tasks on a remote/local machine on your network and search for a process you want for example to terminate.
Here is an example:
For local machine:
TASKLIST /NH /FI " IMAGENAME eq notepad.exe" /FI "STATUS eq running"
For remote machine:
TASKLIST /S %servername% /U %username% /P %password% /NH /FI " IMAGENAME eq notepad.exe" /FI "STATUS eq running"
Another example the tasklist command can be used for is determining the services running under a SVCHOST.EXE process:
TASKLIST /SVC /FI "imagename eq svchost.exe"