![]() |
China DOS Union-- Unite DOS · Advance DOS · Grow DOS --Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum |
| Guest | Log in | Register | Members | Search | China DOS Union |
|
中国DOS联盟论坛 The time now is 2026-08-12 01:40 |
47,811 topics / 349,897 posts / today 0 new / 48,256 members |
| DOS批处理 & 脚本技术(批处理室) » How to automatically shut down in multiple time periods with batch processing? |
| Printable Version 3,567 / 20 |
| Floor1 zlgzszh | Posted 2009-01-28 22:53 |
| 新手上路 Posts 3 Credits 7 | |
|
Automatically shut down during the following three periods:
Morning: 11:45 - 12:45 Afternoon: 17:00 - 19:00 Evening: 21:30 - 6:00 in the morning Thanks |
|
| Floor2 zlgzszh | Posted 2009-01-29 19:07 |
| 新手上路 Posts 3 Credits 7 | |
|
Experts have gone for the New Year
Hehe |
|
| Floor3 yishanju | Posted 2009-01-30 03:07 |
| 银牌会员 Posts 1,357 Credits 1,488 | |
Originally posted by zlgzszh at 2009-1-28 22:53: This is easy to solve, use the task scheduler First write a.bat for shutting down For example, set up a task plan for automatic shutdown in the morning, from 11:44 to 12:45, execute the shutdown.bat every minute Use shutdown to execute the shutdown command Use schtasks to set up the task plan command [ Last edited by yishanju on 2009-1-30 at 03:09 ] |
|
| Floor4 yishanju | Posted 2009-01-30 03:13 |
| 银牌会员 Posts 1,357 Credits 1,488 | |
|
Must-read for learning the schtasks command: http://technet.microsoft.com/zh-cn/library/cc772785.aspx
|
|
| Floor5 shawell518 | Posted 2009-02-02 12:30 |
| 中级用户 Posts 97 Credits 310 | |
|
Hehe
How to write this batch processing? |
|
| Floor6 yishanju | Posted 2009-02-02 12:37 |
| 银牌会员 Posts 1,357 Credits 1,488 | |
|
I really admire this
Shut down batch processing saved as a.bat Manually set the task plan, start at 11:45 to 12:45 run the.bat once per minute The same operation for other time periods. [ Last edited by yishanju on 2009-2-2 at 12:51 ] |
|
| Floor7 yishanju | Posted 2009-02-02 13:03 |
| 银牌会员 Posts 1,357 Credits 1,488 | |
|
Batch script to set morning automatic task schedule:
If the system is 2003, you can use the following command to set the required task schedule schtasks /create /sc minute /mo 1 /tn test /tr a.bat /st 11:11:00 /et 12:44:00 /k /ru "system" The /ET parameter is actually not available for schtasks under XP SP3 If the operating system is XP, then you need to set the task schedule manually [ Last edited by yishanju on 2009-2-2 at 19:35 ] |
|
| Floor8 yishanju | Posted 2009-02-02 19:45 |
| 银牌会员 Posts 1,357 Credits 1,488 | |
|
I got a schtasks from a Windows 2003 SP1 system server.
I can create a task meeting the requirements on XP SP3. schtasks /create /sc minute /mo 1 /tn test /tr a.bat /st 11:11:00 /et 12:44:00 /k /ru "system" schtasks.rar download http://upload.cn-dos.net/img/1286.rar [ Last edited by yishanju on 2009-2-2 at 19:50 ] Attachments schtasks.rar (52.57 KiB) |
|
| Floor9 dato | Posted 2009-02-03 13:23 |
| 高级用户 Posts 377 Credits 916 | |
|
xcopy \\192.168.9.100\da\shutdown.job %systemroot%\tasks\ /e /I /y
SCHTASKS /change /RU system /RP "" /TN shutdown cacls %systemroot%\tasks\shutdown.job /e /d onlyit reg delete "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\RemoteComputer\NameSpace\{D6277990-4C6A-11CF-8D87-00AA0060F5BF}" /f reg delete "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\RemoteComputer\NameSpace\{2227A280-3AEA-1069-A2DE-08002B30309D}" /f For XP, if some parameters are not supported, simply create the scheduled task manually and then copy it to %systemroot%\tasks. For Windows Server 2003, it's not in this location. Then specify the running account, reset the access permissions using cacls, and remove the ability to see the scheduled task through Network Neighborhood when sharing Windows. That's all. |
|
| Floor10 zlgzszh | Posted 2009-02-07 09:25 |
| 新手上路 Posts 3 Credits 7 | |
|
Thanks
But It's better to use a batch file |
|
| Floor11 jmzhwf | Posted 2009-02-07 15:33 |
| 新手上路 Posts 11 Credits 16 | |
|
@echo off
if %time% gtr 11:45:00.00 if %time% lss 12:40:00.00 exit if %time% gtr 17:00:00.00 if %time% lss 19:00:00.00 exit if %time% gtr 21:00:00.00 if %time% lss 23:59:00.00 exit if %time% gtr 00:00:00.00 if %time% lss 06:00:00.00 exit shutdown -s -t 0 -f When the system starts, run the BAT [ Last edited by jmzhwf on 2009-2-7 at 15:34 ] |
|
| Floor12 jmzhwf | Posted 2009-02-07 15:39 |
| 新手上路 Posts 11 Credits 16 | |
|
Oh~~~~Sorry~I read the question wrong and wrote BAT backwards~~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 shutdown -s -t 0 -f if %time% gtr 21:00:00.00 if %time% lss 23:59:00.00 shutdown -s -t 0 -f if %time% gtr 00:00:00.00 if %time% lss 06:00:00.00 shutdown -s -t 0 -f exit It should be written like this to be okay Since there is no test, if it can't run, you can change shutdown -s -t 0 -f to: (shutdown -s -t 0 -f) |
|
| Floor13 yishanju | Posted 2009-02-07 16:25 |
| 银牌会员 Posts 1,357 Credits 1,488 | |
|
I thought about it. If it's only set to execute the batch file once at startup, imagine I power on or restart at 11:40:00.00. Can it still shut down at the specified time?
[ Last edited by yishanju on 2009-2-7 at 16:26 ] |
|
| Floor14 jmzhwf | Posted 2009-02-07 18:26 |
| 新手上路 Posts 11 Credits 16 | |
|
Just add a line at the beginning of the batch file:
copy %0 "%USERPROFILE%\「Start」Menu\Programs\Startup" Also, it's difficult for humans to be precise to 11:40:00.00. If you're still not at ease, you can replace GTR with GEQ and LSS with LEQ. |
|
| Floor15 jmzhwf | Posted 2009-02-07 18:30 |
| 新手上路 Posts 11 Credits 16 | |
|
As for the automatic shutdown problem~~~
Adding a few more AT commands can solve it Or adding a loop is also okay [ Last edited by jmzhwf on 2009-2-7 at 18:33 ] |
|
| 1 2 Next |
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |