0

谁能告诉我为什么这不起作用。当我输入 ether 1 或 2 时我想要它,goto但是当我输入数字时它会继续运行ECHO ERROR任何人都可以帮助:-)。

ECHO OFF

ECHO Loading...

SET option=0

SET /P option=Choose a number and press enter. :

ECHO %option%

if "%option" == "1" GOTO one

if "%option" == "2" GOTO two

GOTO EXIT

:one

ECHO hello

GOTO EXIT

:two

ECHO hi

GOTO EXIT






:EXIT
ECHO EXIT
Taskkill /f /im program.bat 2>%USERPROFILE%\temp.txt



ECHO ERROR

pause
4

2 回答 2

2
if "%option" == "1" GOTO one

if "%option" == "2" GOTO two

这里的收盘百分号在哪里?

于 2013-11-07T11:15:24.853 回答
2

这条线

if "%option" == "1" GOTO one

应该读:

if "%option%" == "1" GOTO one

第二种情况也是如此。

ERROREXIT如果您需要 ; 的案例,它将始终显示为ERROR;

:EXIT
ECHO EXIT
GOTO EOF

ECHO ERROR

:EOF
PAUSE
于 2013-11-07T11:16:03.110 回答