gpt4 book ai didi

if-statement - 批量处理多个 If

转载 作者:行者123 更新时间:2023-12-02 02:11:14 24 4
gpt4 key购买 nike

我已经多次尝试让这个批处理工作,但它不会,这让我发疯。在我屈服于提出问题之前,我还梳理了这个网站并尝试了许多不同的事情。

我有一个批处理程序会根据您的选择执行关机或重启或注销。当我运行它并想通过检查答案以查看它是否为零来从几小时移动到几分钟再到几秒时,问题就出现了。它给出了错误“有一个意外的(”并立即关闭。如果我把它拆开并单独运行它,它就会工作。

这是包含 If 语句的主函数。如果你想看整批,我可以给你。我已经注释掉了 shutdown 的实际使用,只是为了帮助解决这个问题。 REM'd out shutdown 行之前的 2 行将在解决后删除。

:SR_MAIN
cls
echo+
echo+
set /p SR_hrs=....Please enter the number of hours before %SR_NAME%:

IF "%SR_hrs%" == 0 (
echo+
echo You don't want hours, huh?
timeout /t 2 > nul
cls
echo+
echo+
set /p ptm=....Please enter the number of minutes before %SR_NAME%:
IF %ptm% == 0 (
echo+
echo You don't want minutes, huh?
timeout /t 2 > nul
cls
echo+
echo+
set /p pts=....Please enter the number of seconds before %SR_NAME%:
IF %pts% == 0 (
echo+
echo Exiting to Shutdown menu...
timeout /t 2 > nul
goto SHUTREMENU
) ELSE (
cls
echo+
echo+
echo This will %SR_NAME% the computer in the seconds you provided.
set /a tm=pts
echo+
echo Waiting %tm% seconds before continuing...
echo+
timeout /t %tm%
echo Now would come the %SR_NAME%!
pause
REM shutdown /f /%SR_N% /t 0
exit
)
) ELSE (
cls
echo+
echo+
echo This will %SR_NAME% the computer in the minutes you provided.
set /a tm=ptm*60
echo+
echo Waiting %ptm% minutes (%tm% seconds) before continuing...
echo+
timeout /t %tm%
echo Now would come the %SR_NAME%!
pause
REM shutdown /f /%SR_N% /t 0
exit
)
) ELSE (
cls
echo+
echo+
echo This will %SR_NAME% the computer in the hours you provided.
set /a tm=SR_hrs*60*60
echo+
echo Waiting %SR_hrs% hours (%tm% seconds) before continuing...
echo+
timeout /t %tm%
echo Now would come the %SR_NAME%!
pause
REM shutdown /f /%SR_N% /t 0
exit
)

:MAIN_MENU
ECHO Exiting to Main Menu...
PAUSE

感谢您提供的任何帮助。这对我来说是一个真正的难题。

J

最佳答案

缺少一个百分号。

IF "%SR_hrs%" == 0 (

↑ there

关于if-statement - 批量处理多个 If,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12699314/

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