I would like to write a windows script that waits until a given process (PID) has ended before executing something. So far I have (PID=1234):
:loop
set VAR="tasklist | find /i " 1234 " /c"
if NOT (' %VAR% ')=="0" goto loop
**do something**
but already the line
set VAR="tasklist | find /i " 1234 " /c"
doesn't work, it stores the string instead of the evaluation. Or maybe it's supposed to? In which case the line
if NOT (' %VAR% ')=="0" goto loop
should evaluate the contents of VAR, but if I type this manually in a console I just get
"tasklist | find /i " was unexpected
I understand the double quotes in
set VAR="tasklist | find /i " 1234 " /c"
are problematic but I need a space on each side of the PID (1234 in the example) to ensure that it is not a substring of another process (like 12345) for it to work properly.
Any DOS experts out there?