PDA

View Full Version : batch file help



Mike
14-07-2011, 07:59 AM
I am creating a batch file to run as a scheduled task, where I need it to launch 3 processes to run simultaneously, but to not continue until all three have completed?

I have been able to get them to each wait until the previous has completed (using CALL), or all three to launch at once (just launching the process without the CALL)... but I can't get it to do a combination.

Is it possible?


[Batch 1]
call process1.bat
call process2.bat
call process3.bat
call endprocess.bat

[Batch 2]
process1.bat
process2.bat
process3.bat
endprocess.batIn Batch 1, each process will launch after the previous one has finished, and then when all three are completed it will run endprocess.bat.
In Batch 2, each process and the endprocess.bat will launch at the same time.
What I'm trying to do is get each process to launch at the same time, but the endprocess.bat to not occur until ALL THREE processes have completed...

Cheers,
Mike.

inphinity
14-07-2011, 08:18 AM
You'll probably have to use tasklist or pslist or something to check for the processes existing and sleep while they do.

Paul.Cov
14-07-2011, 08:49 AM
A clumsy shameteur way to do it would be to engineer one of the batch files to consistently take the longest to run, and consequently be the last to finish. It can then be the process to call the endprocess.bat routine.

Another option is to have each batch set a file or flag upon completion. Once all 3 flags are set the endprocess batch can be allowed to proceed.

Mike
14-07-2011, 08:53 AM
Another option is to have each batch set a file or flag upon completion. Once all 3 flags are set the endprocess batch can be allowed to proceed.So far I think this will be the easiest solution...

Mike.

fred_fish
14-07-2011, 09:16 AM
Yes.
Set each process to write a sentinel file (s1,s2,s3), then delete it on completion.
Your final process can be run when an "IF NOT EXISTS s?" test returns TRUE.