windows 如何让批处理文件等待另一个批处理文件完成执行?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2572176/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 07:14:30  来源:igfitidea点击:

How can I make the batch file wait until another batch file completes execution?

windowsbatch-filecommand-linescripting

提问by Arunachalam

How can I make a batch file wait until another batch file has finished?

如何让批处理文件等待另一个批处理文件完成?

For example, I have:

例如,我有:

echo hi >r.txt
echo some piece of code >>r.txt 

start ar.bat

echo some piece of code >>ar.txt 

I want the code after start ar.batto execute only after ar.batfinishes executing. I tried without startand it works, but I want to run ar.batin a separate window.

我希望之后的代码start ar.bat仅在ar.bat执行完成后才执行。我试过没有start,它可以工作,但我想ar.bat在单独的窗口中运行。

Is there any method to check whether ar.bathas finished?

有没有什么方法可以检查是否ar.bat已经完成?

回答by Anders Abel

Use call ar.batto do it completely with batch file commands.

用于call ar.bat完全使用批处理文件命令来完成。

Use start /wait ar.batto get another window and wait for it to complete.

使用start /wait ar.bat得到另一个窗口,等待它完成。