I am running many exe through multiple batches. Sometimes it happens that some exes got stuck so I chose to kill them after a timeout, like this:
CD mypath
start myexe.exe
timeout 60
TSKILL myexe
However, since all the exe have the same name, the batch does not close the exe it started but all of them. I also tried this:
cd mypath
for /f "tokens=2 delims==; " %%a in ('start myexe^| find "ProcessId" ') do set MyPID=%%a
timeout 60
taskkill /PID %MyPID% /T
but the timeout
starts just once the exe had finished.
How can I kill the process that the specific batch opened after a timeout?