On 10/19/2016 7:29 PM, Robert Prins wrote:
> This is probably not very difficult, but...
>
> The batch file starts a process, X, waits 10 seconds and starts a second
> process, Y, and another 10 seconds later a third one, Z. I would like to
> add a fourth one, the above scheduled task, to make a hobocopy'ed
> backup, about once per 30 minutes, of a directory updated by process X,
> but that task should somehow stop automatically the moment that process
> X is stopped.
>
> Is there a way to do this?
>
> Thanks
START "" "X"
TIMEOUT 10 & START "" "Y"
TIMEOUT 10 & START "" "Z"
- following checks if X is running and does not proceed until X stops
:_CheckX
TASKLIST /FI "IMAGENAME eq "X" 2> NUL|FINDSTR /I "X" > NUL
IF NOT ERRORLEVEL 1 GOTO CheckX
START "" /WAIT "Robocopy"
-continues here AFTER Robocopy completes
Could add initial SET "_Stime=%time%"
and then after Robocopy completes
check that 30 min elapsed and GOTO beginning of batch