0

I have a simple batch file which calls other batch files, it looks like this:

start /b run_part1.bat start /b run_part2.bat start /b run_part3.bat start /b run_part4.bat run_last.bat // fires immediately, how to make this line wait until above finishes? 

With the /b the first 4 files will run concurrently. All will finish within 1.5 hours.

I need another script to do some cleaning up after all the four files finish. However the run_last.bat will not wait for the first 4 files, it is called at the same time with the first 4.

Is there a way to achieve it?

Thank you.

0

3 Answers 3

2

Stop using the antiquated command prompt and use Powershell. You can use the ThreadJob module, as described in this excellent answer on SO:

$commands = { ./run_part1.bat }, { ./run_part2.bat }, { ./run_part3.bat }, { ./run_part4.bat } $jobs = $commands | Foreach-Object { Start-ThreadJob $_ } $jobs | Receive-Job -Wait -AutoRemoveJob ./run_last.bat 
0

you can use CALL ,it calls one bath file from another bath file

for more information check https://www.robvanderwoude.com/call.php

0

There is nothing built-in to batch files to handle this.

You can modify the 4 batch files to create a flag file when they are done. Then in the main batch file, run a loop looking for the flag files with a call to timeout /t 10 in the loop to slow down the checks.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.