To terminate an application using the taskkill command, you first need to identify its Process ID (PID) or its Image Name (IM - the executable filename). The tasklist command is the standard utility for finding this information.
You can use the built-in Windows Task Manager for a quick visual reference or the tasklist command-line utility for a scriptable method.
Method 1: Using the Command Line (tasklist)
Open Command Prompt or PowerShell and use the tasklist command to get a list of all running processes:
tasklist
Use code with caution.
The output will be a table listing the Image Name, the PID, Session Name, Session #, and Mem Usage for every running process:
Image Name           PID Session Name    Session#  Mem Usage
========================= ======== ================ =========== ============
System Idle Process       0 Services          0     8 K
System              4 Services          0   4,300 K
smss.exe            392 Services          0   1,212 K
...
chrome.exe          1520 Console          1  254,120 K
notepad.exe          5120 Console          1   4,500 K
explorer.exe         4200 Console          1   85,124 K
Filtering the output
If the list is long, you can use findstr to filter for a specific application name:
tasklist | findstr "notepad"
Use code with caution.
This will quickly show you the image name (notepad.exe) and the associated PID (5120 in the example above).
Method 2: Using the Task Manager (GUI)
For a simple visual approach, you can use the Windows Task Manager:
Press Ctrl+Shift+Esc to open Task Manager.
Go to the Details tab (in Windows 10/11) or the Processes tab (in older Windows versions and the simplified view).
Locate the application's executable file name under the Name (or Image Name) column.
The corresponding PID is listed in the column right next to it.
Using the Information with taskkill
Once you have identified the necessary information:
To kill by Image Name (notepad.exe):
taskkill /IM notepad.exe
Use code with caution.
To kill by PID (5120):
taskkill /PID 5120
Use code with caution.
It is highly recommended to add the /F switch to forcefully terminate the process if it is unresponsive:
taskkill /F /IM notepad.exe