gpt4 book ai didi

batch-file - if 语句不工作批处理(直接转到 else)

转载 作者:行者123 更新时间:2023-12-03 09:36:23 27 4
gpt4 key购买 nike

我只是在为我的批处理文件设置密码;但是,我的 if 语句不起作用。当我要求它检查我的密码是否正确时,它会转到 else 语句,即使我正确输入了密码(嗨)。
这是我的代码中有问题的部分:

if "%R%"=="hi" (
goto b
) else (
echo access denied.
goto f
)

这是整个代码:
echo off
color 0f
pause

:f
set /p R = "Please enter your passcode "

if "%R%"=="hi" (
goto b
) else (
echo access denied.
goto f
)

:a
for /L %%A IN (1,1,234) DO (
color 6e
echo %random%%random%%random%%random%%random%%random%%random%
color 2a
echo %random%%random%%random%%random%%random%%random%%random%%random%
color 1b
echo %random%%random%%random%%random%%random%%random%%random%%random%
color 5d
echo %random%%random%%random%%random%%random%%random%%random%%random%
color 4c
echo %random%%random%%random%%random%%random%%random%%random%%random%
)
GOTO c

:b
echo Welcome Back
pause >nul
echo Your current computer does not contain previous files.
pause >nul
echo Download Backup Files now?
pause >nul
echo Downloading all Files...
goto a

:c
echo access granted. welcome to the CIA Mainframe.
pause >nul
echo Please se-se-select a c-command.
pause >nul
echo Alert! Alert! The main Fire wall has been Breached!
pause >nul
echo Files being deleted now...
pause >nul

:d
color 0c
echo %random%%random%%random%%random%%random%%random%%random%
echo %random%%random%%random%%random%%random%%random%%random%%random%
echo %random%%random%%random%%random%%random%%random%%random%%random%
echo %random%%random%%random%%random%%random%%random%%random%%random%
echo %random%%random%%random%%random%%random%%random%%random%%random%
goto d

任何人都可以请帮忙。

最佳答案

这是变量中空格的问题。

从命令行试试这个:

>set /p R = "Please enter your passcode: "
Please enter your passcode: blah

>echo %R%
%R%

>echo %R %
blah

将您的线路更改为:
set /p "R=Please enter your passcode: "

这应该解决。

关于batch-file - if 语句不工作批处理(直接转到 else),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36781647/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com