Search This Blog

Sunday, September 16, 2012

How to start several processes from the Windows shell and wait for them all to complete?

i found this easy solution to achieve this

main.bat

start cmd /c proc1.bat
start cmd /c proc2.bat
:wait
sleep 1
IF NOT EXIST proc1done GOTO wait
IF NOT EXIST proc2done GOTO wait
del proc1done
del proc2done
echo All processes are complete

proc1.bat
proc1.exe
echo Done > proc1done


The sleep command is available in Windows Server 2003 Resource Kit Tools. If you don't have that, you could use a ping on localhost just to slow down that tight loop.