@echo off&setlocal enabledelayedexpansion
title ~定時(shí)關(guān)機(jī)嘍~
color 3f
::http://hi.baidu.com/zhuge000
echo.&echo.
echo.&echo 定時(shí)關(guān)機(jī)批處理
echo.
echo ================================================================================
echo ===================================★junge ★===================================
echo.
call :logo
echo.
ping /n 2 127.1 >nul
net start|findstr "Scheduler">nul&&goto come
sc config Schedule start= auto >nul 2>nul
net start Schedule >nul 2>nul
:come
cls&color 3f
echo.&call :logo
echo Enter: 定制關(guān)機(jī)任務(wù),直接按回車
echo.
echo f: 輸入f再回車,查看已定制任務(wù)
echo.&echo.&echo.
set "zhouyongjun="&set /p zhouyongjun= 請(qǐng)選擇:
if not defined zhouyongjun goto main
set "zhouyongjun=%zhouyongjun: =%"&set "zhouyongjun=!zhouyongjun:~0,1!"
if "%zhouyongjun%"=="f" goto ok
call :error&goto come
:main
cls&color 3f
call :logo
set "t="&set /p t= 請(qǐng)輸入自動(dòng)關(guān)機(jī)時(shí)間(24小時(shí)制):
if not defined t goto main
set "t=%t: =%"
if not defined t goto main
for /f "tokens=1,2 delims=:" %%i in ("%t%") do (set "tm1=%%i"&set "tm2=%%j")
set /a tm1=100%tm1%%%100&set /a tm2=100%tm2%%%100
if %tm1% geq 24 goto cuowu
if %tm2% geq 60 goto cuowu
set t=%tm1%:%tm2%
echo.&echo.
echo 每天此時(shí)關(guān)機(jī)輸入e再回車,僅一次直接按回車
echo.&set "v="&set /p v= Enter/e:
if "%v%"=="" goto sz1
set "v=%v: =%"&set "v=!v:~0,1!"
if "%v%"=="e" goto sz2
call :error
goto main
:sz1
at %t% shutdown -s -t 00 >nul
call :px&goto ok
:sz2
at %t% /every:一,二,三,四,五,六,日 shutdown -s -t 00 >nul
call :px&goto ok
:ok
cls&color 3f
call :logo
echo 任務(wù)列表
echo.
set "t1="&set "zyj="&set "zyj1="&set "zyj2="&set /a n=0
for /f "skip=2 tokens=1,2,3" %%a in ('at') do (
set /a n+=1&set t1=%%a&set t2=%%b&set t3=%%c&call :output)
echo.
echo c.創(chuàng)建關(guān)機(jī)任務(wù)
echo d.刪除關(guān)機(jī)任務(wù)(刪除單個(gè):d+ID號(hào),如d1,d2;刪除所有:da)
echo q.退出
set /p zyj= 請(qǐng)輸入:
if "%zyj%"=="" goto ok
set "zyj=%zyj: =%"&set "zyj1=!zyj:~0,1!"&set "zyj2=!zyj:~1,1!"
if "%zyj1%" equ "d" if "%zyj2%" equ "a" (at /del /y >nul&goto :ok)
if "%zyj1%"=="d" goto drw
if "%zyj1%"=="c" goto main
if "%zyj1%"=="q" goto :eof
call :error
goto ok
:drw
if "%t1%"=="" goto ok
if "%zyj2%"=="" goto ok
set /a m+=1
set "ws=!zyj:~%m%,1!"
if not "%ws%"=="" goto drw
set /a m-=1
set "zyj2=!zyj:~1,%m%!"
set /a m=0
for /l %%i in (1,1,%n%) do (if %zyj2% equ %%i (at %%i /del /y&&call :px&goto ok)
)
call :error&goto ok
:px
set /a x=0&set /a y=0
for /r "%windir%\tasks\" %%h in (At*.job) do (set /a x+=1&ren %%h "_#!x!.job")
for /r "%windir%\tasks\" %%p in (_#*.job) do (set /a y+=1&ren %%p "At!y!.job")
goto :eof
:output
if "%t1%"=="" goto :eof
echo %t2%|findstr/i "每月">nul 2>nul&&set "t2=每天"
echo ID:%t1% %t2% %t3% 關(guān)機(jī)
goto :eof
:cuowu
cls&color 4e
echo.&echo.&echo.&echo.&echo.&echo.
echo 您老人家輸入的時(shí)間不合法?。?!
ping /n 3 127.1>nul
goto main
:error
color 4e&echo.
echo 您老人家輸入有誤,請(qǐng)重新輸入!
ping /n 3 127.1>nul
cls
goto :eof
:logo
echo.&echo %date%
echo.
echo ===========================================================================
echo 啦啦啦,我是關(guān)機(jī)批處理~~O(∩_∩)O哈哈~~
echo ===========================================================================
echo.