Click here to Skip to main content
15,887,683 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a special requirement where i am trying to run child bat files from a master bat file. But there are multiple issues that i am running into.
1. Master does not wait for child to get completed and completes without waiting for child file completion. Which means i can not schedule it as job.
2. When i am doing parallel execution inside master file, it does not go to the next line of execution.
I am posting a high level scenario, please let me know the correct way of doing it.


parent A (don't finish till all child and grandchild are done)
----------->parallel child 1
---------------------->grandchild a
---------------------->grandchild b
--------------------------------->parallel great grandchild b1
--------------------------------->parallel great grandchild b2
---------------------->grandchild c (don't start this till both great grandchild b1 and great grandchild b2 are done)
---------------------->grandchild d
--------------------------------->parallel great grandchild d1
--------------------------------->parallel great grandchild d2
-----------> parallel child 2
---------------------->grandchild d
---------------------->grandchild e
--------------------------------->parallel great grandchild e1
--------------------------------->parallel great grandchild e2
---------------------->grandchild f (don't start this till both great grandchild e1 and great grandchild e2 are done)
---------------------->grandchild g
--------------------------------->parallel great grandchild g1
--------------------------------->parallel great grandchild g2

Any help would be appreciated.

What I have tried:

I have tried the parallel execution using Start and normal series execution but it does not work for me in this case.
Posted
Updated 10-Aug-16 23:01pm

I have no idea how you're launching the other batch files, because you don't show the code, but you can always use START /WAIT batchFile parameters to launch it and wait for it to complete.
 
Share this answer
 
Hi Dave,

i am adding a reference code for you.

Code for Master file:-
start "C:\Test\Parallel_batch_process\chlidA.bat"
start "C:\Test\Parallel_batch_process\chlidB.bat"

ChildA:-

start "test1" cmd.exe /C ^(ping server1 -n 2 ^> C:\Test\Parallel_batch_process\Test1.txt^)
start "test2" cmd.exe /C ^(ping server2 -n 2 ^> C:\Test\Parallel_batch_process\Test2.txt^)


ChildB:-
start "test1" cmd.exe /C ^(ping Server3 -n 5 ^> C:\Test\Parallel_batch_process\Test3.txt^)
start "test2" cmd.exe /C ^(ping Server4 -n 2 ^> C:\Test\Parallel_batch_process\Test4.txt^)

There is one more extension to this where i am calling GrandChild from the Child files, but for if this much only works then i can go for the next level.
 
Share this answer
 
Comments
Richard MacCutchan 11-Aug-16 5:55am    
I do not think that you are going to solve this just using batch files, you most likely need to run these commands from a Windows application that can schedule them correctly and ensure that the correct commands complete before proceeding to the next one.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900