The basic one, ask tasklist to filter its output and only show the indicated process id information
tasklist /fi "pid eq 4444"
To only get the process name, the line must be splitted
for /f "delims=," %%a in ('
tasklist /fi "pid eq 4444" /nh /fo:csv
') do echo %%~a
In this case, the list of processes is retrieved without headers (/nh
) in csv format (/fo:csv
). The commas are used as token delimiters and the first token in the line is the image name
note: In some windows versions (one of them, my case, is the spanish windows xp version), the pid filter in the tasklist does not work. In this case, the filter over the list of processes must be done out of the command
for /f "delims=," %%a in ('
tasklist /fo:csv /nh ^| findstr /b /r /c:"[^,]*,\"4444\","
') do echo %%~a
This will generate the task list and filter it searching for the process id in the second column of the csv output.
edited: alternatively, you can suppose what has been made by the team that translated the OS to spanish. I don’t know what can happen in other locales.
tasklist /fi "idp eq 4444"
You can find Process Name from Process ID (PID) using the command tasklist in command line windows, apart from command prompt, you can even get process name for the associated Process ID (PID) using either Task Manager or Resource Monitor.
You can get Process Name from Process ID (PID) using the command tasklist in command prompt. TaskList command displays all running applications and associated services with their Process ID (PID).
The following command displays the associated Process Name for the Process ID 488.
tasklist /svc /FI "PID eq 488"
Get Process Name by Process ID (PID) from Remote Computer:
Use below command If you want to get Process Name from Process ID (PID) from Remote Computer.
tasklist /s "remote-pc" /svc /FI "PID eq 488"
Find Process Name from PID through Task Manager
1. Open the Task Manger, click the menu View and click Select Columns.
2. Select the column Process Identifier(PID) and click OK.
3. Now you can find Process Name (Image Name) by mapping PID value.
The process identifier (a.k.a. process ID or PID) is a number used to uniquely identify an active process.
In this short note i will show how to display information about the Windows process (incl. the process name and path to an executable file) by PID from the command-line prompt (CMD) or a Windows PowerShell.
Cool Tip: List processes in Windows from the CMD! Read more →
Execute the tasklist
command to get the process name from PID:
C:\> tasklist /FI "pid eq <pid>"
– or –
C:\> tasklist /FI "pid eq <pid>" /V /FO List
Option | Description |
---|---|
/FI |
Displays a set of tasks that match a given criteria specified by the filter |
/V |
Displays verbose task information |
/FO |
Specifies the output format |
More information about the process by its PID (including the full path to an executable file) can be retrieved using the wmic
command:
C:\> wmic process where "ProcessID=<pid>" get /format:list
Cool Tip: Kill a hanging process in Windows from the CMD! Read more →
Was it useful? Share this post with the world!
Contents
- 1 How to Kill a Process in Windows 10 with Task Manager
- 2 How to Kill a Process with the Taskkill Command
- 3 How to Terminate a Process with PowerShell
- 4 How to Identify the Process of any Open System Dialog or Program Window with Process Explorer
- 5 How to Kill Any Window-related Process Directly with just Two Clicks
For the most part, Windows 10 programs function just fine, but when one misbehaves it’s often necessary to kill its process. At times, apps can refuse to close, get stuck on a blank screen, or suddenly consume a lot of system resources. Terminating the task will force it to close and free up your system for normal functioning.
Identifying and killing a process of single windows and background apps
There are various ways to kill a process, but all of them make use of an application’s PID (Process ID), a unique identifier that ensures only the correct one is terminated. However, it’s worth noting that terminating a specific application process can still have knock-on effects on the rest of the program’s functions if they rely on it.
The most common way in Windows to terminate a process is through Task Manager. But today we’ll also be covering how to kill a process with PowerShell, how use the taskkill command in Command Prompt, how to find a process ID with Process Explorer (Microsofts ooptional advanced Task Manager) and using a two-click-method via a task bar button.
Different methods to kill a process for different needs
Some programs run several processes at once which means if you want to terminate the application completely you will have to kill all those processes. And there are cases where you will have a program window or system dialog but cannot identify the underlying process. In our tutorial you will find solutions for all of those issues.
How to Kill a Process in Windows 10 with Task Manager
Task Manager is the bread and butter of Windows 10 task killers, providing a simple interface with all the information users need to make informed decisions about which applications they should close. Accessing it is as easy as pressing “Ctrl + Shift + Esc”.
- View more details
After opening Task Manager with “Ctrl + Shift + Esc”, press the “More details” button in the bottom left to view more information.
- Select the process you want to kill and click “End task”
You can also press the “Delete” key instead to save some time.
- OR: Find an individual process and terminate it
Click the “Details” tab, find your process, and click “End Task” or press “Delete”.
How to Kill a Process with the Taskkill Command
If task manager isn’t an option because you’re using a Windows server install or it’s blocked by your administrator, you can achieve similar results through the use of the taskkill command in Command Prompt.
- Open Command Prompt
Press the Windows key and type “Command Prompt”, then choose “Run as administrator”.
- Run the tasklist command
You can get a quick readout of all the currently running processes, much like Task Manager, by typing
tasklist | more
and pressing “Enter” - Run the taskkill command to kill the process
Type
taskkill /F /PID x
, wherex
is replaced by your process’ PID. - OR: Use taskkill to kill a process by its name
If you know the name of the process’ .exe file, you can optionally use that to kill the task instead:
taskkill /IM "yourprocess.exe" /F
How to Terminate a Process with PowerShell
Alternatively, those familiar with PowerShell can use it kill tasks instead. This has the advantage of quite intuitive commands.
- Open PowerShell as an admin
Press “Windows + X” to open the fly-out menu, then click “Windows PowerShell (Administrator)”.
- Get a list of processes
In PowerShell, type
Get-Process
to have it return a list of all of the currently running processes on your PC and their PID. - Use PowerShell stop process to kill the task
To stop the process, type the following, substituting the x for the relevant PID:
Stop-Process -ID x -Force
- OR: Kill process by name in PowerShell
As with command prompt, you can also kill one or more processes at once in PowerShell by their name. This time, however, you’ll need its system name rather than its .exe file. For example:
Stop-Process -Name "YourPhone" -Force
How to Identify the Process of any Open System Dialog or Program Window with Process Explorer
As you’ve likely realized by now, scrolling through a giant list to get the name or PID of an application can be an annoyance. To remedy this, you can use Microsoft’s Process Explorer.
- Download Process Explorer
Head to Microsoft’s Process Explorer documentation and press the “Download Process Explorer” button to download the application.
- Run Process Explorer
Head to the folder you downloaded the application to and double-click “Procexp64.exe” or “proxexp.exe” depending on whether your system is 64 or 32-bit.
- Kill a process with Process Explorer
You can use Process Explorer much like Task manager by clicking the application and pressing the ‘x’ button in the top toolbar to stop it.
- Optional: Use the identification crosshair
Alternatively, if you don’t know the name of the application or its process, click the target button in the top toolbar.
- Drag the target to the process you want to identify
The process will then be automatically selected in the list and you can stop it as normal.
Though all of the above methods work just fine, if you find yourself having to kill tasks regularly they still aren’t ideal. For such use cases, we recommend Grizzly Bear’s “Kill”, a tiny 205KB app that you can pin to your taskbar to kill window process with two clicks.
- Download Kill
Go to the dcmembers site and download the Kill.exe freeware by pressing the big blue “Download” button.
- Pin Kill.exe to the taskbar
In the kill folder, right-click “Kill.exe” and select “Pin to taskbar”.
- Kill any window process with Kill.exe
To kill a process, simply click the button on your taskbar and then click on the application window.
If you found this tutorial helpful, you may also be interested in our guides about changing process affinity and OneDrive syncing any directory via mklink.
On a database, I can get a list of all the currently running processes, and the sql command that kicked them off.
I’d like to do a similar thing on a windows box.
I can get the list of processes, but not the command line that kicked them off.
My question is: Given a PID on Windows — how do I find the command line instruction that executed it?
Assumptions:
- Windows 7 and equivalent servers
asked Jun 3, 2015 at 22:55
Powershell and WMI.
Get-WmiObject Win32_Process | Select ProcessId,CommandLine
Or
Get-WmiObject -Query "SELECT CommandLine FROM Win32_Process WHERE ProcessID = 3352"
Note that you have to have permissions to access this information about a process. So you might have to run the command as admin if the process you want to know about is running in a privileged context.
answered Jun 3, 2015 at 23:20
Ryan RiesRyan Ries
55.5k10 gold badges142 silver badges199 bronze badges
8
You can use the WMI subsystem, using WMIC.EXE to get to this information. Assuming a PID of 600:
wmic.exe path Win32_Process where handle='600' get name, commandline /format:list
You can also search for name, or other characteristic of the process. Use this command to list all attributes:
wmic.exe path Win32_Process get /format:list
answered Jun 3, 2015 at 23:39
RobWRobW
2,8061 gold badge19 silver badges22 bronze badges
4
The other answers are certainly good options that will serve you well in an automated system because of their command line nature (and I see from the tag that that’s what you wanted). Of course, some folks might want to explore this kind of info with a GUI, so here’s an alternative along those lines.
Process Explorer is a Sysinternals tool maintained by Microsoft. It can display the command line of the process in the process’s properties dialog as well as the parent that launched it, though the name of that process may no longer be available. Here’s the process properties dialog:
If you want a more detailed audit trail of when a process was launched and under what conditions, you can turn to another Sysinternals tool called Process Monitor. Here you can filter for «Process started» events, learn about the environment the process was launched in, and see what other events were occurring around that time. It’s quite a powerful program. Here’s the event properties dialog:
BE77Y
2,6673 gold badges18 silver badges23 bronze badges
answered Jun 4, 2015 at 7:26
CorrodiasCorrodias
2811 silver badge3 bronze badges
6
To complement Ryan Ries’ helpful PowerShell answer with a shorter alternative via the -Filter
parameter that also uses Get-CimInstance
instead of the deprecated-since-v3 Get-WmiObject
cmdlet.
# Target a process by its PID (process ID) and report its command line,
# using the PowerShell session's own PID as an example ($PID).
(Get-CimInstance Win32_Process -Filter "ProcessId=$PID").CommandLine
# Alternatively, target process(es) by name (may return multiple processes),
# using Notepad.exe as an example.
# Select-Object is used to report both the PID and the command line.
Get-CimInstance Win32_Process -Filter "Name='Notepad.exe'" |
Select-Object ProcessId, CommandLine
The -Filter
parameter essentially allows you to pass the WHERE
clause of a WQL statement instead of passing a full query statement via -Query
.
answered Dec 18, 2018 at 23:26
mklementmklement
5665 silver badges11 bronze badges
You must log in to answer this question.
Not the answer you’re looking for? Browse other questions tagged
.
Not the answer you’re looking for? Browse other questions tagged
.