定时关机 v1.0(autoshut v1.0)

@echo   off
::     flie:autoshut.bat
title 定时关机 v1 . 0 ( autoshut v1 . 0 )
:MENU
cls
COLOR 8A
set  op = ""
ECHO .
ECHO .
ECHO .                    定时关机 v1 . 0 ( autoshut v1 . 0 )
ECHO .                                 CODE BY t0nsha@ 070701
ECHO .                                 Blog :http : // blog . csdn . net / t0nsha
echo .                                 Email :liaodunxia @gmail . com
ECHO .            主菜单 ( menu )
ECHO .           【 1 】启用定时关机 ( scheduled shutdown )
ECHO .           【 2 】取消定时关机 ( cancel scheduler )
ECHO .           【 3 】禁用定时关机 ( disable scheduler )
ECHO .           【v】查看已计划关机任务 ( view  tasks )
ECHO .           【q】退出 ( quit )

set   / p op = 请选择服务项目的数字号并回车 ( Please enter a number ) [ 123 ]:
if  %op% == ""   goto  error
rem  第一个选项具有默认选项的功能!
if  %op% == 1   goto  autoshut
if  %op% == 2   goto  cancel
if  %op% == 3   goto  disable
if   " %op% " == " v "   goto   view
if   " %op% " == " q "   goto  quit

:error
cls
COLOR 8C
ECHO .
ECHO .
echo .                    输入有误!请重试!
echo .             A wrong  choice  received! Please try again!
pause
goto  menu

:autoshut
1 > nul  2 > nul sc config Schedule  start =  auto
1 > nul  2 > nul  net   start   " Task Scheduler "
set   / p hhmm = " 请输入一个时间(格式:hh:mm): "
at %hhmm% shutdown -s -t 
60  -c  " 此关机是由autoshut.bat计划的!(This is initialized by autoshut.bat) "
goto  judge

:cancel
at |
find   " 此关机 " &&  for   / " eol=; skip=2 tokens=1 delims=  "  %%i in  ( 'at' )   do  at %%i  / del
shutdown -a
goto  judge

:disable
net  stop  " Task Scheduler "
sc config Schedule 
start =  disable
goto  judge

:view
cls
ECHO .
ECHO .
at&
pause
goto  judge

:: ::::::::::::::::::::::judge:::::::::::::::::::::
:judge
if   errorlevel   0   if   not   errorlevel   1   goto  success
goto  failure

:success
cls
color 8E
ECHO .
ECHO .
echo .                    恭喜,设置成功!按任意键返回主菜单。
echo .           Job done ... Congratulation! Press any key to continue .
pause > nul
goto  MENU

:failure
cls
COLOR 8C
ECHO .
ECHO .
echo .                   Sorry,设置失败!建议重新运行此程序。
echo .                 Something failed! You should retry later .
pause > nul
goto  MENU

:quit
cls
echo .
echo .
echo .
echo .                          谢谢使用!再见! 
echo .                          Thank you! Bye!
echo   on  &  endlocal  & ping -n  1   127.1   > nul &  goto   :eof
 

你可能感兴趣的:(auto)