简体   繁体   English

如果VAR批处理文件不起作用

[英]IF VAR batch file not working

Can any one tell me why this is not working. 谁能告诉我为什么这不起作用。 i want it to goto when i type ether 1 or 2 but it keeps going to ECHO ERROR when i type the number can any one help :-). 我想在我输入以太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
if "%option" == "1" GOTO one

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

Where is the closing percent sign here? 收盘价百分号在哪里?

This line 这条线

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

should read: 应该读:

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

ditto for the second case. 同上第二种情况。

ERROR will always be displayed as it will fall through from EXIT , if you want a case for ERROR ; ERROR将始终显示,因为它会从上往下坠落通过EXIT ,如果你想为的情况下ERROR ;

:EXIT
ECHO EXIT
GOTO EOF

ECHO ERROR

:EOF
PAUSE

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM