Reputation: 2406
I have a batch script A. This script run an .exe application and after a while, the script A stop the .exe application. My problem is I run my script A in several shell. Consequently, I execute several times simultaneously the same .exe application (but with different PID)
My question is, in batch, how can I run an external .exe and get his PID ? If I run the exe and I catch his PID, I can stop the "good" .exe.
Upvotes: 1
Views: 177
Reputation: 26
For /f "tokens=2 delims=;= " %A in ('wmic process call create notepad.exe ^| findstr /c:ProcessId') Do Echo %A
For is the command to get output from a command. WMIC returns the PID for programs it starts.
wmic process call create notepad.exe
In a batch file use %%A
rather than %A
when typing.
Upvotes: 1