Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/batch-file/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Batch file 如何使批处理程序中途停止_Batch File - Fatal编程技术网

Batch file 如何使批处理程序中途停止

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

我正在制作一个批处理程序,我想中途停止。我只希望它在调用其他命令时执行它们,比如:Command。我有办法做到这一点吗?我不想暂停,我希望它不要播放下面的其他命令。我想让它停止代码的运行。因此,在调用命令之前,它不会播放任何命令。示例如下:

@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