这个问题对于Windows批处理文件,我试图从主文件运行多个批处理文件 [英] This question for windows batch file where I am trying to run multiple batch file from master file

查看:83
本文介绍了这个问题对于Windows批处理文件,我试图从主文件运行多个批处理文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个特殊要求,我试图从主蝙蝠文件中运行子蝙蝠文件。但是我遇到了很多问题。

1. Master不等待孩子完成并完成而不等待子文件完成。这意味着我无法将其作为工作安排。

2.当我在主文件中执行并行执行时,它不会进入下一行执行。

I我发布了一个高级别的场景,请让我知道正确的方法。





父母A(不要完成直到所有孩子和孙子都完成了)

----------->平行孩子1

----------- ----------->孙子a

---------------------->孙子b

--------------------------------->并行孙子b1

--------------------------------->并行大孙子b2

---------------------->孙子c(不要开始这个,直到大孙子b1和大孙子b2完成)

---------------------->孙子d

------------- -------------------->并行曾孙子d1

---------------- ----------------->并行大孙子d2

----------->平行儿童2

---------------------->孙子d

----- ----------------->孙子e

--------------------- ------------>并行孙子e1

------------------------ --------->并行大孙子e2

---------------------->孙子f(在伟大的孙子e1和曾孙子孙完成之前不要开始这个)

---------------------->孙子g

---------------------------------> parallel grand grandchild g1

--------------------------------->并行孙子g2



任何帮助将不胜感激。



我尝试过:



我尝试使用Start和普通系列执行并行执行,但在这种情况下它对我不起作用。

解决方案

我不知道你是如何启动其他批处理文件的,因为你没有显示代码,但是你总是可以使用 START / WAIT batchFile 参数 来启动它并等待它完成。

Hi Dave,



i我为你添加一个参考代码。



主文件代码: -

startC:\Test \Parallel_batch_process\chlidA.bat

startC:\Test \Parallel_batch_process \\ \\ chlidB.bat



ChildA: -



启动test1cmd.exe / C ^ (ping server1 -n 2 ^> C:\Test \Parallel_batch_process \Test1.txt ^)

启动test2cmd.exe / C ^(ping server2 -n 2 ^> C:\Test \Parallel_batch_process \ Test2.txt ^)





ChildB: -

启动test1cmd.exe / C ^(ping Server3 -n 5 ^> C:\Test \Parallel_batch_process \ Test3.txt ^)

启动test2cmd.exe / C ^(ping Server4 -n 2 ^> C:\Test \Parallel_batch_process \ Test4.txt ^)



还有一个扩展名,我从子文件调用GrandChild ,但是,如果这只有效,那么我可以进入下一个级别。


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.

解决方案

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.


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.


这篇关于这个问题对于Windows批处理文件,我试图从主文件运行多个批处理文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆