问题描述
我比调用的主批处理文件4其他批处理文件,所以我们可以并行运行。
I have a main batch file than calls 4 other batch files so we can run in parallel.
例如:
Main.bat
start call batch1.bat
start call batch2.bat
start call batch3.bat
start call batch4.bat
exit
我希望所有的BATCH1批4已经停止执行后,Main.bat退出。通过这种方式,我可以得到批处理文件的总运行时间。问题是Main.bat退出BATCH1到batch4执行完毕之前也。
I want the Main.bat to exit after all the batch1 to batch 4 has stopped executing. In this way, I can get the total run time of the batch file. Problem is Main.bat exits even before batch1 to batch4 finishes executing.
我试图来计算%ERRORLEVEL%每批文件,但它始终返回0,即使4 .bat文件仍在运行。
I tried to compute for %errorlevel% for each batch file, but it always return 0 even though the 4 .bat files are still running.
希望有人能帮帮我!
感谢您! :)
推荐答案
我觉得这是最简单,最有效的方式:
I think this is the simplest and most efficient way:
@echo off
echo %time%
(
start call batch1.bat
start call batch2.bat
start call batch3.bat
start call batch4.bat
) | set /P "="
echo %time%
在此方法中的主要文件中的等待状态的事件驱动的,所以它不占用任何CPU!
In this method the waiting state in the main file is event driven, so it does not consume any cpu!
这篇关于如何等待所有批处理文件在退出前完成?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!