![]() |
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-06 09:10 |
48,039 topics / 350,124 posts / today 0 new / 48,251 members |
| DOS批处理 & 脚本技术(批处理室) » Please provide more details such as how many minutes to set for the automatic shutdown, etc. If you want to set it to shut down after 30 minutes, the following is a simple batch code: ```batch @echo off shutdown -s -t 1800 ``` Here, `-s` means to start the shutdown operation, and `-t` followed by 1800 means 1800 seconds, which is 30 minutes. If you want to set a different time, you just need to change the number after `-t`. For example, if you want to shut down after 60 minutes, change 1800 to 3600. |
| Printable Version 1,958 / 9 |
| Floor1 okmhy | Posted 2007-06-12 20:28 |
| 新手上路 Posts 7 Credits 15 | |
|
I am too rubbish. Please find a batch script for automatic shutdown at a scheduled time:
Requirements: 1. When the computer starts, automatically detect whether it is morning or afternoon. If it is morning, set automatic shutdown at 12 o'clock. If it is afternoon, set automatic shutdown at 17 o'clock. 2. If the computer is started before 8 o'clock in the morning, between 12 o'clock and 13 o'clock, or after 17 o'clock in the evening, automatically shut down. Or cannot start? Please help me, thank you in advance, dear experts! |
|
| Floor2 jamesbond | Posted 2007-06-12 23:59 |
| 新手上路 Posts 2 Credits 4 | |
|
Just use AT commands. You make it sound so complicated.
|
|
| Floor3 baomaboy | Posted 2007-06-13 00:10 |
| 银牌会员 Posts 554 Credits 1,513 | |
|
Can set scheduled shutdown and can query and change tasks: System Shutdown Management → VBS Version
|
|
| Floor4 HAT | Posted 2007-06-13 12:55 |
| 版主 Posts 5,017 Credits 9,023 | |
|
The code was posted incorrectly, sweat, modify it.
[ Last edited by HAT on 2007-6-13 at 09:13 PM ] |
|
| Floor5 okmhy | Posted 2007-06-13 19:05 |
| 新手上路 Posts 7 Credits 15 | |
|
Thank you very much for the replies from the 3rd and 4th floors. I've learned something.
|
|
| Floor6 okmhy | Posted 2007-06-13 19:21 |
| 新手上路 Posts 7 Credits 15 | |
|
The `%time:~0,2%` is a substring extraction operation in batch scripting. In batch, for a variable that holds a time value, like `%time%`, the `~` is used for substring extraction. The syntax `%variable:~start,length%` means to extract a substring starting at position `start` with a length of `length`. Here, `%time:~0,2%` is extracting the first 2 characters from the `%time%` variable which represents the hour part of the time. So `set t=%time:~0,2%` is setting the variable `t` to the hour part of the current time.
|
|
| Floor7 HAT | Posted 2007-06-13 21:06 |
| 版主 Posts 5,017 Credits 9,023 | |
|
The code on the 4th floor has been corrected.
[ Last edited by HAT on 2007-6-13 at 09:14 PM ] |
|
| Floor8 HAT | Posted 2007-06-13 21:08 |
| 版主 Posts 5,017 Credits 9,023 | |
|
```
//The part after : %time:~,0,2% I don't understand. Can you explain the parameters? set t=%time:~0,2% This means taking the first two digits of the current system time (that is, the hour value)
[ Last edited by HAT on 2007-6-13 at 09:14 PM ] ``` |
|
| Floor9 aaa2117 | Posted 2007-11-01 16:44 |
| 初级用户 Posts 15 Credits 30 | |
|
It doesn't work when the system service isn't started
|
|
| Floor10 ldr2zjj | Posted 2007-11-01 20:21 |
| 初级用户 Posts 95 Credits 167 | |
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |