I would like to find if an application is open and get it's PID. For this, I used,
wmic process where name="notepad.exe" get ProcessId
If there are two, notepad.exe
s open, it shows 2 PID's. I want to taskkill
one if 2 are open. How would I approach doing this. How can I check if there are 2 of the same named processes(with specific names) open at a time? Is there a way I can store the tasklist
in a list?
I think this is what you want:
It will output the process count and the PIDs as a comma-separated list. Here's the output if i run it against
chrome.exe
: