In Command Prompt (CMD), tasklist
and taskkill
are essential commands for managing processes on a Windows system. They allow users to monitor, troubleshoot, and terminate processes, which can be useful for improving system performance or resolving issues with unresponsive applications.
tasklist
Command
The tasklist
command provides a list of all currently running processes, showing important information such as process IDs (PIDs), memory usage, and the status of each process. This command is commonly used for monitoring system activity and identifying processes that may be consuming excessive resources.
Basic Usage
To display a list of all running processes:
tasklist
This command will show a table of processes, including their names, PIDs, session names, and memory usage.
Filtering Output with tasklist
The tasklist
command also supports filters to help narrow down the results.
-
Filter by Process Name: To display processes of a specific name, use the
/fi
switch:tasklist /fi "imagename eq notepad.exe"
This will show only the processes with the name
notepad.exe
. -
Display with Verbose Output: The
/v
switch adds more detailed information, such as the status and the window title for GUI-based processes:tasklist /v
-
Show Specific Process Information: You can filter based on the PID or session name using
/fi
with specific criteria. For example:tasklist /fi "pid eq 1234"
This will show information about the process with the PID of
1234
.
Example of tasklist
Output
Image Name PID Session Name Session# Mem Usage
========================= ======== ================ =========== ============
explorer.exe 1056 Console 1 20,000 K
notepad.exe 1248 Console 1 5,000 K
This shows the process name, PID, memory usage, and other details.
taskkill
Command
The taskkill
command is used to terminate a running process by specifying either its process ID (PID) or image name. It is helpful when a process becomes unresponsive and needs to be forcefully terminated.
Basic Usage
To terminate a process using its PID:
taskkill /PID 1234
Replace 1234
with the actual PID of the process you wish to terminate.
Terminate a Process by Name
You can also kill processes by their image name:
taskkill /IM notepad.exe
This will terminate all instances of notepad.exe
running on the system.
Forcefully Terminate a Process
The /f
option forces the termination of a process, even if it’s not responding. This is useful for unresponsive programs that can’t be closed normally.
taskkill /f /IM notepad.exe
This will forcefully terminate all instances of notepad.exe
.
Terminate a Process and Its Child Processes
The /t
switch allows you to terminate the specified process and all its child processes. This is useful when a parent process spawns additional background tasks.
taskkill /f /IM notepad.exe /t
This will forcefully kill notepad.exe
and any processes that were launched by it.
Example of taskkill
Usage
To terminate a specific process with the PID 5678
:
taskkill /PID 5678
To forcefully terminate chrome.exe
:
taskkill /f /IM chrome.exe