Batch file 如何使批处理程序中途停止
我正在制作一个批处理程序,我想中途停止。我只希望它在调用其他命令时执行它们,比如:Command。我有办法做到这一点吗?我不想暂停,我希望它不要播放下面的其他命令。我想让它停止代码的运行。因此,在调用命令之前,它不会播放任何命令。示例如下:Batch file 如何使批处理程序中途停止,batch-file,Batch File,我正在制作一个批处理程序,我想中途停止。我只希望它在调用其他命令时执行它们,比如:Command。我有办法做到这一点吗?我不想暂停,我希望它不要播放下面的其他命令。我想让它停止代码的运行。因此,在调用命令之前,它不会播放任何命令。示例如下: @echo off :Talk Echo DONT DO THIS PART UNTIL CALLED :NoName echo Going to Talk goto :Talk 通常的方法是退出或转到eof。另外,goto也很有帮助: 使用goto:eo
@echo off
:Talk
Echo DONT DO THIS PART UNTIL CALLED
:NoName
echo Going to Talk
goto :Talk
通常的方法是退出或转到eof。另外,
goto
也很有帮助:
使用goto:eof
(意思是:“转到脚本末尾”):
使用退出
:
set /p "x=Enter a command: "
if /i "%x%"="talk" call talk
exit /b
echo this line will never be reached
:talk
echo going to talk
goto :eof
使用goto
:
:input
set /p "x=Enter a command: "
if /i "%x%"="talk" call talk
goto :input
echo this line will never be reached
:talk
echo going to talk
goto :eof
换句话说:用
goto:eof
结束每个被调用的“子例程”,你能举一个例子说明你到目前为止所做的吗?现在还不完全清楚您想要做什么,以及为什么它必须是一个批处理文件而不是另一种类型的脚本?
:input
set /p "x=Enter a command: "
if /i "%x%"="talk" call talk
goto :input
echo this line will never be reached
:talk
echo going to talk
goto :eof