中国DOS联盟论坛

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 11:47
47,811 topics / 349,897 posts / today 0 new / 48,256 members
DOS批处理 & 脚本技术(批处理室) » [Help]Smart batch shutdown Those who are experts come in
Printable Version  3,990 / 19
Floor1 515808051 Posted 2006-12-02 16:41
新手上路 Posts 7 Credits 16
It can be said that I don't understand this aspect at all. I found this batch script for automatically shutting down when the network is disconnected from the Internet.

@echo off
:start
ping XXX.XXX.XXX.XXX
if errorlevel 1 goto end
goto start
:end
shutdown -s -t 600
exit

What I want to ask (for help) is whether it can be made more intelligent. For example, if the ping to XXX.XXX.XXX.XXX is successful, the next command, which is the shutdown command, will not be executed. If it is not successful, it must definitely shut down. The problem is here. I want to delay the shutdown for 30 minutes, that is, shutdown -s -t 1800. Within 30 minutes, if the ping to XXX.XXX.XXX.XXX is successful, cancel the shutdown command shutdown -a and then re-detect the IP. If it is possible, it would be better to detect multiple different IPs. I can't change it well (fooling around). I think it's difficult. Maybe there is no such batch script. That's probably the general meaning. If there are other methods, it's also okay. If it's not possible or there are some third tools or other methods, please teach me.
Floor2 lxmxn Posted 2006-12-02 17:58
版主 Posts 4,938 Credits 11,386


The code hasn't been tested. If it doesn't work, follow up with a discussion.

P.S.: The www.cn-dos.com in the original post has been changed to www.cn-dos.net.


[ Last edited by lxmxn on 2006-12-3 at 07:03 AM ]
Floor3 515808051 Posted 2006-12-02 20:44
新手上路 Posts 7 Credits 16
Thanks, come to help, no way if it doesn't work.

I looked at this batch processing, read the tutorial, and still feel a bit confused.

I don't know what friend lxmxn wrote above means.

I can understand just a few simple commands, although it's not useful, but

I already know basic commands, but I don't even understand basic commands...

I found this BBS in the search and came to take a look to see how much I can learn.

[ Last edited by 515808051 on 2006-12-2 at 07:53 AM ]
Floor4 electronixtar Posted 2006-12-03 01:27
铂金会员 Posts 2,672 Credits 7,493

ping www.cn-dos.com


Is it www.cn-dos.net?
Floor5 weapfe Posted 2006-12-03 01:56
初级用户 Posts 66 Credits 144
:eof course, the translation is:

CODE:
--------------------------------------------------------------------------------

@echo off
ping www.cn-dos.com -n 1 >nul 2>nul || (shutdown -s -t 1800
:KO
ping www.baidu.com -n -1 >nul 2>nul && shutdown -a ||goto KO)
goto :eof

What is ":eof" in the sentence?
Floor6 vkill Posted 2006-12-03 02:06
金牌会员 Posts 1,744 Credits 4,103 From 甘肃.临泽
I'm not a pro~ I made a mistake recently
Floor7 515808051 Posted 2006-12-03 02:24
新手上路 Posts 7 Credits 16
Still no one. Is there any way? I can only do this now

@echo off
:start
ping XXX.XXX.XXX.XXX
if errorlevel 1 goto and
goto start
:and
ping XXX.XXX.XXX.XXX
if errorlevel 1 goto bnd
goto start
:bnd
ping XXX.XXX.XXX.XXX
if errorlevel 1 goto cnd
goto start
:cnd
Just repeating several IP addresses. No way.
shutdown -s -t 600
exit
Floor8 lbccyxs Posted 2006-12-03 02:30
初级用户 Posts 27 Credits 54
At least, you need to add a delay statement. Otherwise, the network resources and local resources will be consumed too much. Even if it is possible, it is useless!!!
Floor9 tao0610 Posted 2006-12-03 03:20
高级用户 Posts 218 Credits 579
Floor10 515808051 Posted 2006-12-03 04:17
新手上路 Posts 7 Credits 16
I also looked it up online, and some people asked whether it can be delayed, but no one answered this question. If someone knew how, they wouldn't be asking for help. Whether it works or not depends on the person.
Floor11 tao0610 Posted 2006-12-03 04:36
高级用户 Posts 218 Credits 579
You can use the forum search more!

Click me click me click me
Floor12 9527 Posted 2006-12-03 04:51
银牌会员 Posts 438 Credits 1,185 From 北京
I really don't know why both of you have this picture? Is it just a coincidence?
Floor13 515808051 Posted 2006-12-03 05:04
新手上路 Posts 7 Credits 16
Originally posted by tao0610 at 2006-12-2 03:36 PM:
Use the forum search more!

Click me Click me Click me


Thanks, but how to use it... It was made clear at the beginning. Just one word... Don't want to say

The picture is not clever. Pay attention to my signature
Floor14 zh159 Posted 2006-12-03 05:54
金牌会员 Posts 1,467 Credits 3,687
The building owner's: sleep 10, unit seconds
5th floor: sleep 10000, unit milliseconds
Floor15 weapfe Posted 2006-12-03 06:07
初级用户 Posts 66 Credits 144
The building owner's seems a bit~~~
Why does the window become smaller as soon as I use the "sleep" command (provided that I first copy it to the system32 directory), but it's okay with F5~~
In doubt~~
1 2  Next
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023