[英]How to pause a batch script on a command
I have a below batch script:我有一个下面的批处理脚本:
@echo off
cd C:\Program Files (x86)\Project
CALL init_env.bat
cd C:\Users\Documents\Project\Release
START app.exe -ver 133
echo application has been stopped
This starts the app.exe
.这将启动app.exe
。 On the terminal it also says application has been stopped
.在终端上它还说application has been stopped
。 Is there any way I can pause the script after executing the line START app.exe -ver 133
and only run echo application has been stopped
when the app was closed or crashed for some reason.有什么方法可以在执行START app.exe -ver 133
行后暂停脚本,并且仅在应用程序因某种原因关闭或崩溃时echo application has been stopped
。
Thanks谢谢
The command START
should be removed because it starts the executable app.exe
as separate process being executed parallel to cmd.exe
processing the batch file.应该删除命令START
,因为它将可执行app.exe
作为与处理批处理文件的cmd.exe
并行执行的单独进程启动。 Then cmd.exe
processing the batch file starts app.exe
and waits with further processing of the batch file until app.exe
terminated itself.然后cmd.exe
处理批处理文件启动app.exe
并等待批处理文件的进一步处理,直到app.exe
终止。
It is also recommended to always enclose a file/folder string in "
even on not really being necessary. So cd /D "C:\Program Files (x86)\Project"
and call "init_env.bat"
should be used or even better call "C:\Program Files (x86)\Project\init_env.bat"
if that works also because of batch file init_env.bat
is written to work independent on what is the current directory on execution. And last cd /D "C:\Users\Documents\Project\Release"
and "app.exe" -ver 133
should be written in the batch file.还建议始终将文件/文件夹字符串包含在"
中,即使不是真的需要。因此应该使用cd /D "C:\Program Files (x86)\Project"
并call "init_env.bat"
甚至更好call "C:\Program Files (x86)\Project\init_env.bat"
,如果这也有效,因为批处理文件init_env.bat
被写入独立于执行时的当前目录。最后cd /D "C:\Users\Documents\Project\Release"
和"app.exe" -ver 133
应写入批处理文件。
Run in a command prompt window cd /?
在命令提示符下运行 window cd /?
for help on command CD and meaning of option /D
.有关命令CD的帮助和选项/D
的含义。
start /?
outputs the help for command START in cmd window.输出 cmd window 中命令START的帮助。
@echo off
call "C:\Program Files (x86)\Project\init_env.bat"
cd /D "C:\Users\Documents\Project\Release"
"app.exe" -ver 133
echo application has been stopped
See also the predefined Windows environment variables .另请参阅预定义的Windows 环境变量。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.