Score:0

cmd - run a batch file after all other concurrent batch files finish

ru flag
Cal

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.

Score:2
in flag

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 
Score:0
us flag

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

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

Score:0
uz flag

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.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.