我必须为约1000个工作站提供批处理文件,以编辑一些注册表项并重新启动计算机。我已经用注册表项解决了所有问题,但是我想给出一个Y / N提示重启。到目前为止,我有:
@echo off
setlocal
:PROMPT
SET /P AREYOUSURE=To continue, the workstation must reboot. Would you like to reboot now (Y/[N])?
IF /I "%AREYOUSURE%" NEQ "Y" GOTO END
echo ... rest of file ...
:END
endlocal
shutdown.exe /r /t 00
这是我的第一次尝试,无论按什么键,它似乎都会重新启动。关于我可能在这里做错的任何指示?
答案 0 :(得分:0)
这有效-
@ECHO Off
SET /P yesno=Do you want to Reboot this machine? [Y/N]:
IF "%yesno%"=="y" GOTO Confirmation
IF "%yesno%"=="Y" GOTO Confirmation
IF "%yesno%"=="n" GOTO End
IF "%yesno%"=="N" GOTO End
:Confirmation
ECHO System is going to Reboot now
shutdown.exe /r
GOTO EOF
:End
ECHO System Reboot cancelled
TIMEOUT 5 >nul
:EOF
exit