China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-10-02 09:59
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » How to automatically shut down in multiple time periods with batch processing? View 3,903 Replies 20
Floor 16 Posted 2009-02-08 18:18 ·  中国 福建 三明 电信
高级用户
★★
论坛上抢劫的
Credits 551
Posts 246
Joined 2006-09-21 12:35
20-year member
UID 63270
Status Offline
set sj=%time:~0,2%%time:~3,2%
if %sj%>1145 (if %sj%<1245 shutdown -s -t 10)
Floor 17 Posted 2009-03-14 21:13 ·  中国 北京 电信
中级用户
★★
Credits 310
Posts 97
Joined 2004-05-26 00:00
22-year member
UID 25372
Gender Male
Status Offline
Originally posted by lotus516 at 2009-2-8 06:18 PM:
set sj=%time:~0,2%%time:~3,2%
if %sj%>1145 (if %sj%<1245 shutdown -s -t 10)


Hehe
Not tried
Learned
Three time periods
Floor 18 Posted 2009-03-14 21:24 ·  中国 北京 电信
中级用户
★★
Credits 310
Posts 97
Joined 2004-05-26 00:00
22-year member
UID 25372
Gender Male
Status Offline
Originally posted by jmzhwf at 2009-2-7 03:39 PM:
Oh~~~~Sorry~I read the question wrong and reversed the BAT~~hehe

@echo off
if %time% gtr 11:45:00.00 if %time% lss 12:40:00.00 shutdown -s -t 0 -f
if %time% gtr 17:00:00.00 if %time% lss 19:00:00.00 s ...


Tried it
Can't run
Floor 19 Posted 2009-08-25 08:39 ·  IANA 局域网IP(Private-Use)
新手上路
★
Credits 1
Posts 1
Joined 2009-08-15 05:54
17-year member
UID 150404
Gender Male
Status Offline
At most, wait, wait, wait, wait, wait
Floor 20 Posted 2010-07-22 20:03 ·  中国 四川 成都 电信
新手上路
★
Credits 3
Posts 3
Joined 2010-07-19 00:06
16-year member
UID 170728
Gender Male
Status Offline
I also want to achieve this function
Floor 21 Posted 2010-07-23 12:42 ·  中国 广东 东莞 电信
银牌会员
★★★
批处理编程迷
Credits 1,916
Posts 752
Joined 2008-12-28 04:30
17-year member
UID 135147
Gender Male
From 广西
Status Offline
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 ]
精简
=> 个人网志
Forum Jump: