2017-03-13 247 views
1

我已经阅读以下两篇文章,发现他们都没有回答我的问题How to call one batch file after anotherExecute batch file after another batch file completes执行多个批处理文件后,同时完成批处理文件

我试图通过Windows Server 2012 R2 Standard上的批处理文件运行一系列6个Python脚本。我想要前5个脚本同时运行(Processing.bat),它目前由五个子bat文件(North.bat,West.bat,South.bat,Central.bat,Northeast.bat)组成。一旦完成,它应该运行一个最终脚本,与前5个(Merge.bat)的输出一起工作。

我已经尝试了几个组合的调用和开始/等待,没有什么似乎做对了。目前,我的主要bat文件看起来像:

start /wait Processing.bat 
start /wait Merge.bat 

Processing.bat样子:

start North.bat 
start South.bat 
start NorthEast.bat 
start West.bat 
start Central.bat 

IF %ERRORLEVEL% EQU 0 EXIT 

每个子蝙蝠的样子:

start /wait C:\Python27\ArcGIS10.4\python.exe E:\TestScript.py Central 

IF %ERRORLEVEL% EQU 0 EXIT 

最后merge.bat样子:

start /wait C:\Python27\ArcGIS10.4\python.exe E:\MergeSDE.py 

IF %ERRORLEVEL% EQU 0 EXIT 

W如果使用此设置,所有6个脚本将立即运行(而不是5个,然后是1)。但各个命令提示符窗口将保持打开状态,直到每个脚本完成(7个窗口)。踢球者是,如果我要将Processing.bat中的“start”改为“start/wait”,它将会依次运行每一个(我不想要的前5个),然后用“start/wait “在主要批次中,所有分批次都一次运行。

+0

可能重复[如何等待所有批处理文件完成之前退出?](http://stackoverflow.com/questions/33584587/how-to-wait-all-batch-files-to-finish-before-退出) – aschipfl

回答

1

由于它是批处理文件,假设您可以编辑它们。

组在第一创建一个标志文件的末尾:

break>"%temp%\north" 

第二:

break>"%temp%\south" 

等为他人。

在merge.bat集的开头(如果west.bat是最后一个执行文件):

:wait_again 
:: sleep 5 seconds 
ping 127.0.0.1 -n 6 > nul 
if not exist "%temp%\south" if not exist "%temp%\north" ... (

    goto :wait_again 
) 

merge.bat应该开始command.Also的标志文件应该被删除再次启动提前。

+0

你能指定'merge.bat'中语法的位置吗? '启动C:\ Python27 \ ArcGIS10.4 \ python.exe E:\ RSA_Automation \ SimultaneousScripts \ MergeSDE.py IF%ERRORLEVEL%EQU 0 EXIT' – dji43466

+0

@ dji43466 - 前'开始..'线 – npocmaka