How do I Continue a batch file only if a process IS running

Posted by Shane McD on Stack Overflow See other posts from Stack Overflow or by Shane McD
Published on 2010-06-03T15:23:12Z Indexed on 2010/06/06 23:42 UTC
Read the original article Hit count: 390

Filed under:
|
|
|

I have successfully managed to hold a batch file until a process ends. But how do I hold a batch file until a process starts?

I am working using the following code:

@echo off

set process_1="calc.exe"
set process_2="mmc.exe"
set ignore_result=INFO:
set no_ignore=mmc.exe

:1
for /f "usebackq" %%M in (`tasklist /nh /fi "imagename eq %process_1%"`) do if not %%M==%ignore_result% goto 1
:2
for /f "usebackq" %%N in (`tasklist /nh /fi "imagename eq %process_2%"`) do if not %%N==%no_ignore% goto 2

echo Stuff finished.......

All I get when the program isn't running is "INFO: No tasks running with the specified criteria"

Thanks in advance

S

© Stack Overflow or respective owner

Related posts about process

Related posts about batch