标题: 帮我弄一下关机批处理
[打印本页]
作者: luuk
时间: 2010-4-19 13:24
标题: 帮我弄一下关机批处理
原文:
===========================================
@echo off
title 选择关机
color 3f
set /p chioce= 请输入命令\ 重启【r】\关机【s】\退出【q】
if %chioce%==r goto reboot
if %chioce%==s goto shutdown
if %chioce%==q goto end
:reboot
shutdown -r /t 10
goto rechioce
:shutdown
shutdown -s /t 10
goto rechioce
:rechioce
color f3
title 要取消关机吗
set chioce=
set /p chioce=取消关机【c】
if %chioce%==c goto cancle
goto end
:cancle
cls
shutdown -a
goto end
:end
exit
=========================================
在执行第一个选择命令是,敲入"e"等其他字母(不是q r s ),也会跳出关机提示,不是应该报错吗?
作者: slore
时间: 2010-4-19 13:31
代码依次执行
if %chioce%==r goto reboot
if %chioce%==s goto shutdown
if %chioce%==q goto end
::这里上面3个判断都没有成立
::如果你不转到别的地方就继续向下执行
::所以加一个:
goto :end
::当然你可以再输入的上面设置一个标签,如果不是那些
::字母的话跳过去重新输入
:reboot
shutdown -r /t 10
goto rechioce
作者: luuk
时间: 2010-4-19 14:12
如果不是设定的字母返回重新输入,怎么写语句啊?
作者: luuk
时间: 2010-4-19 14:14
哦,,明白啦
thank U