计划关机工具

来源:互联网 发布:塔人网络接收奇迹世界 编辑:程序博客网 时间:2024/06/03 15:58

//使用shutdown命令制作的windows计划关机工具,可在指定时间后执行关机或重启。

//文件名:计划关机.bat

//代码:

:Begin

@cls
@if "%~1"=="" color 8f&mode con cols=60 lines=15
@title 计划关机_Beswor
@echo==========欢迎使用计划关机工具 From Beswor============
@echo.
@set hh=0
@set mm=0
@set ss=0
@set type=0
@set /p type=0.取消 1.关机 2.重启 :
@if /i %type%==0 goto Cancle
@set str=关机(默认)
@if /i %type%==1 set str=关机
@if /i %type%==2 set str=重启
@if /i "%str%"=="关机(默认)" goto Begin
@echo.
:H
@set /p hh=【小时】:
@echo %hh%|findstr /be "[0-9]*" >nul &&set /a Res=1||set /a Res=0
@if %Res% EQU 1 (if %hh% GEQ 0 (goto M))
@echo !数字错误(大于等于0)
@goto H
:M
@set /p mm=【分钟】:
@echo %mm%|findstr /be "[0-9]*" >nul &&set /a Res=1||set /a Res=0
@if %Res% EQU 1 (if %mm% GEQ 0 (if %mm% LSS 60 (goto S)))
@echo !数字错误(大于等于0,小于60)
@goto M
:S
@set /p ss=【秒钟】:
@echo %ss%|findstr /be "[0-9]*" >nul &&set /a Res=1||set /a Res=0
@if %Res% EQU 1 (if %ss% GEQ 0 (if %ss% LSS 60 (goto Pre)))
@echo !数字错误(大于等于0,小于60)
@goto S


:Pre
@echo.
@echo ■%hh%小时%mm%分%ss%秒后%str%■


@set /p x=准备就绪,按回车键执行...
@set /a time=%hh%*3600+%mm%*60+%ss%
@if /i "%str%"=="关机" shutdown /s /t %time%
@if /i "%str%"=="重启" shutdown /r /t %time%
@ping 127.0.0.1 -n 2 >nul
@exit


:Cancle
@shutdown /a
@echo 已取消
@ping 127.0.0.1 -n 2 >nul
@exit