Tasklist Command in Windows
Tasklist command in Windows displays a list of applications and services with their Process ID (PID) for all tasks running on either a local or a remote computer.
You will need tasklist command to troubleshoot issues related to your appserver, webserver domains or database if using Windows Servers as the OS platforms to host your appservers, webservers or database.
An example of a real-life issue could be that the appserver domain may give error during the bootup process due to port conflict. You may try to delete the cache folder after shutting down the appserver, but it won’t let you to because there may be a process using the folder.
You can use tasklist command in similar situations to see if you can gather further information about a process, which is usually not visible in Task Manager.
Syntax
tasklist[.exe] [/s computer] [/u domain\user [/p password]] [/fo {TABLE|LIST|CSV}] [/nh] [/fi FilterName [/fi FilterName2 [ … ]]] [/m [ModuleName] | /svc | /v]
Parameters
/s Computer : Specifies the name or IP address of a remote computer (do not use backslashes). The default is the local computer.
/u Domain \ User : Runs the command with the account permissions of the user specified by User or Domain\User. The default is the permissions of the current logged on user on the computer issuing the command.
/p Password : Specifies the password of the user account that is specified in the /u parameter.
/fo { TABLE | LIST | CSV } : Specifies the format to use for the output. Valid values are TABLE, LIST, and CSV. The default format for output is TABLE.
/nh : Suppresses column headers in the output. Valid when the /fo parameter is set to TABLE or CSV.
/fi FilterName : Specifies the types of process(es) to include in or exclude from the query.
/m [ ModuleName ] : Specifies to show module information for each process. When a module is specified, all the processes using that module are shown. When a module is not specified, all the processes for all the modules are shown. Cannot be used with the /svc or the /v parameter.
/svc : Lists all the service information for each process without truncation. Valid when the /fo parameter is set to TABLE. Cannot be used with the /m or the /vparameter.
/v : Specifies that verbose task information be displayed in the output. Cannot be used with the /svc or the /m parameter.
/? : Displays help at the command prompt.
Example:
I will use the the most likely command you will end up using in most of the occasions:
tasklist /svc
It will list out all the tasks running as shown below:
Image Name PID Services
========================= ======== =======================
System Idle Process 0 N/A
System 4 N/A
smss.exe 256 N/A
csrss.exe 352 N/A
csrss.exe 400 N/A
psxss.exe 408 N/A
wininit.exe 440 N/A
winlogon.exe 448 N/A
services.exe 516 N/A
lsass.exe 524 Netlogon, SamSs
lsm.exe 532 N/A
If you need to terminate a task – you can use taskkill command.