重起电脑按R,关机按S,取消按C,重新执行上一命令按B
參考答案:@echo off
:TOP
echo *****************
echo 重起电脑按R,关机按S,取消按C,重新执行上一命令按B
echo *****************
set /p Key=请按键(R/S/C/B):
:DEALING
if %Key% equ R ( echo R > %tmp%\0.tmp & shutdown -r -t 30)
if %Key% equ S ( echo S > %tmp%\0.tmp & shutdown -s -t 30)
if %Key% equ C ( echo C > %tmp%\0.tmp & shutdown -a)
if %Key% equ B (
if not exist %tmp%\0.tmp ( echo B > %tmp%\0.tmp & goto TOP)
for /f %%i in (%tmp%\0.tmp) do (
if %%i equ B (goto TOP)
echo B > %tmp%\0.tmp
set Key=%%i
goto DEALING
)
)