[英]windows batch file The system cannot find the batch label specified-exit
I'm having a problem with a DOS batch file and labels.我的 DOS 批处理文件和标签有问题。 I keep getting this error: there are two batch files(QQ.bat and Calling.bat) in the same folder.我不断收到此错误:同一文件夹中有两个批处理文件(QQ.bat 和 Calling.bat)。
the code of QQ.bat: QQ.bat代码:
@echo off
set /a i=0
:loop
set /a i=i+1
echo %i%
c:
cd \Users
cd mytool
cd QQ
cd Bin
QQ.exe
if "%i%"=="2" goto exit
goto loop
The code of Calling.bat: Calling.bat的代码:
@echo off
set/a i=0
:loop
set/a i=i+1
start /b cmd /c QQ.bat
if "%i%"=="4" exit
goto loop
pause
the console's output "The system cannot find the batch label specified -exit",and excute severl QQ.exe by random and the amount is not correct ,while my excepted result is that there will be excute 8 QQ.exe simultaneously.控制台输出“系统找不到指定的批处理标签-退出”,随机执行severl QQ.exe,数量不正确,而我排除的结果是同时执行8个QQ.exe。
The console shows an error because GOTO statement is trying to jump to a label which doesn't exist.控制台显示错误,因为GOTO语句试图跳转到不存在的标签。
From what I can understand by the use of goto exit in your script is that you want the script to exit at that point.从我在脚本中使用 goto exit 可以理解的是,您希望脚本在该点退出。 For that use:对于这种用途:
GOTO:EOF
instead of goto exit
. GOTO:EOF
而不是goto exit
。
This should do what your code is doing: QQ.exe
is launched 8
times - but your code is reusing the %i%
variable so you may not need it 8 times.这应该完成您的代码正在执行的操作: QQ.exe
启动了8
次 - 但您的代码正在重用%i%
变量,因此您可能不需要它 8 次。
@echo off
for /L %%a in (1,1,8) do start "" /d "c:\Users\mytool\QQ\Bin" "QQ.exe"
You have correctly defined labels, but incorrectly interpreted goto syntax.您已正确定义标签,但错误地解释了 goto 语法。 Use "goto :exit" instead.改用“goto :exit”。 You can find help on batch command by executing it with "/?"您可以通过使用“/?”执行批处理命令来找到有关批处理命令的帮助。 in command line (like "goto /?" )在命令行中(如 "goto /?" )
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.