等待可执行文件完成运行 [英] Wait for executable to finish running
本文介绍了等待可执行文件完成运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您可以在批处理文件中运行两个可执行文件,然后等待第一个进程结束再开始下一个进程吗?
Can you run two executables in a batch file and wait for the first process to end before starting the next?
推荐答案
使用开始/等待:
:NOTEPAD
start /wait notepad.exe
IF %ERRORLEVEL% == 0 goto NEXTITEM1
else goto QUIT
:NEXTITEM1
start /wait mplayer.exe
IF %ERRORLEVEL% == 0 goto NEXTITEM2
else goto QUIT
:NEXTITEM2
start /wait explorer.exe
IF %ERRORLEVEL% == 0 goto NEXTITEM3
else goto QUIT
:NEXTITEM3
REM You get the idea...
:QUIT
exit
此外,使用NT CMD而不是BAT(myscript.cmd).
In addition, use NT CMD rather than BAT (myscript.cmd).
为回应这些评论,从上面的脚本中删除了%ERRORLEVEL%周围的方括号.以下似乎表现出预期的效果:
In response to the comments, brackets removed from the above script around %ERRORLEVEL%. The following seems to behave as expected:
:NOTEPAD
start /wait notepad.exe || goto QUIT
:NEXTITEM1
start /wait mplayer2.exe || goto QUIT
:NEXTITEM2
REM You get the idea...
:QUIT
exit
双管道之后的语句仅在失败之前执行.
The statement after the double-pipe only executes if what is before it fails.
这篇关于等待可执行文件完成运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文