【发布时间】:2017-03-13 19:08:44
【问题描述】:
我已经阅读了以下两个帖子,发现他们似乎都没有回答我的问题How to call one batch file after another、Execute 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) 的输出一起使用。
我尝试了几种 call 和 start /wait 的组合,但似乎都没有做对。目前我的主要 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
使用此设置,所有 6 个脚本将同时运行(而不是 5 个后跟 1 个)。但相应的命令提示符窗口将保持打开状态,直到每个脚本完成(7 个窗口)。更重要的是,如果我将 Processing.bat 中的“开始”更改为“开始/等待”,它将一个接一个地运行(前 5 个中的哪一个,我不想要),但使用“开始/等待” " 在主批次中,所有子批次同时运行。
【问题讨论】:
标签: python windows batch-file cmd nested