I get two results when I run this:
tasklist /FI "imagename eq PROCESS.exe"
Image Name PID Session Name Session# Mem Usage
========================= ======== ================ =========== ============
PROCESS.exe 2760 Console 1 8,156 K
PROCESS.exe 20160 Console 1 9,060 K
But I only want to kill ONE of them...
If I open up the Task Manager, I can see that each of my processes have different descriptions.
So all I need to do, is somehow filter by process description.
Can anyone help, please?
Thank you!
Use the following to distinguish the processes according to their own process ID and their parent process ID:
wmic process get processid,parentprocessid,executablepath | find "PROCESS"
This way, you can find the process ID to kill.
wmic grants access to additional process properties.
Use wmic process get /? to find out what is available.
Another potentially helpful tool is PsList of Microsoft/Sysinternals.
If you want to filter your process list by the window title, just use
tasklist /FI "windowtitle eq Title"
As addition to @Axel's answer with WMI - the same for description:
WMIC Process WHERE "Description='Only One'" GET ProcessID
And in VBS:
Set objWMIService = GetObject("winmgmts:\\.\root\CIMV2")
Set colItems = objWMIService.ExecQuery( _
"SELECT * FROM Win32_Process WHERE Description = 'My Desc'",,48)
For Each objItem in colItems
'Do Stuff
Next
Another possible value for description is the assembly's description which is retrievable with PowerShell. Use Get-Process to obtain the assembly path and retrieve its description with [System.Diagnostics.FileVersionInfo]::GetVersionInfo($File).FileDescription.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With