这是我以前用过的,精确到小时。
**在限制的时间内开机会自动关机。
**在关机前5分钟,警告一次。
**运行一次即开启
@echo off&setlocal enabledelayedexpansion
(set str=xxxxxxxaxxxaaxxxxaaaaaaaxx
rem x为限制时间,a为开放时间,以小时为单位,从0小时开始
set g=!str:~%time:~,2%,1!
for /l %%a in (%time:~,2%,1,25) do if "!str:~%%a,1!" equ "!g!" (set gg=0%%a) else (goto :ok)
)
:ok
(
if !g! neq x (
echo;y|schtasks /delete /tn "%~1"
echo;a|schtasks /Create /tn "学习计划" /tr "%~f0 学习计划" /ru "用户名" /rp "密码" /sc minute /mo 5 /st %gg:~-2%:55:00 /ed 2010/06/30
rem 失效日期:2010/06/30
del /q %temp%\close.ben
goto :eof)
if exist %temp%\close.ben (
Shutdown.exe -s -t 1
echo;a|schtasks /create /tn "启动运行" /tr "%~f0 启动运行" /ru "用户名" /rp "密码" /sc onstart
goto :eof)
)1>nul 2>nul
(
mode con cols=30 lines=6
echo;>%temp%\close.ben
echo; 保证充足的睡眠!
echo; 好好学习,天天向上!
echo; 快保存,五分钟后关机!
ping -n 5 127.1 1>nul
goto :eof
)
:granf
Last edited by netbenton on 2010-7-25 at 16:54 ]
This is what I used before, precise to the hour.
**It will automatically shut down when powered on within the restricted time.
**Warn once 5 minutes before shutting down.
**Run once to enable
@echo off&setlocal enabledelayedexpansion
(set str=xxxxxxxaxxxaaxxxxaaaaaaaxx
rem x is the restricted time, a is the open time, in hours, starting from 0 hour
set g=!str:~%time:~,2%,1!
for /l %%a in (%time:~,2%,1,25) do if "!str:~%%a,1!" equ "!g!" (set gg=0%%a) else (goto :ok)
)
:ok
(
if !g! neq x (
echo;y|schtasks /delete /tn "%~1"
echo;a|schtasks /Create /tn "Learning Plan" /tr "%~f0 Learning Plan" /ru "Username" /rp "Password" /sc minute /mo 5 /st %gg:~-2%:55:00 /ed 2010/06/30
rem Expiration date: 2010/06/30
del /q %temp%\close.ben
goto :eof)
if exist %temp%\close.ben (
Shutdown.exe -s -t 1
echo;a|schtasks /create /tn "Startup Run" /tr "%~f0 Startup Run" /ru "Username" /rp "Password" /sc onstart
goto :eof)
)1>nul 2>nul
(
mode con cols=30 lines=6
echo;>%temp%\close.ben
echo; Ensure sufficient sleep!
echo; Study hard and make progress every day!
echo; Save quickly, shut down in five minutes!
ping -n 5 127.1 1>nul
goto :eof
)
:granf
Last edited by netbenton on 2010-7-25 at 16:54 ]