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-08-12 11:00
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » [Help]Smart batch shutdown Those who are experts come in View 3,986 Replies 19
Original Poster Posted 2006-12-02 16:41 ·  中国 海南 三亚 电信
新手上路
Credits 16
Posts 7
Joined 2006-12-02 16:07
19-year member
UID 72384
Gender Male
Status Offline
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.
Floor 2 Posted 2006-12-02 17:58 ·  中国 湖北 武汉 电信
版主
★★★★★
Credits 11,386
Posts 4,938
Joined 2006-07-23 17:10
20-year member
UID 59080
Status Offline


@echo off
ping www.cn-dos.net -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

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 ]
Floor 3 Posted 2006-12-02 20:44 ·  中国 海南 三亚 电信
新手上路
Credits 16
Posts 7
Joined 2006-12-02 16:07
19-year member
UID 72384
Gender Male
Status Offline
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 ]
借用 lxmxn 头像
莫见怪
Floor 4 Posted 2006-12-03 01:27 ·  中国 四川 成都 教育网
铂金会员
★★★★
Credits 7,493
Posts 2,672
Joined 2005-09-02 00:00
20-year member
UID 42173
Gender Male
Status Offline

ping www.cn-dos.com


Is it www.cn-dos.net?

C:\>BLOG http://initiative.yo2.cn/
C:\>hh.exe ntcmds.chm::/ntcmds.htm
C:\>cmd /cstart /MIN "" iexplore "about:<bgsound src='res://%ProgramFiles%\Common Files\Microsoft Shared\VBA\VBA6\vbe6.dll/10/5432'>"
Floor 5 Posted 2006-12-03 01:56 ·  中国 江苏 苏州 中移铁通
初级用户
★★
Credits 144
Posts 66
Joined 2006-11-30 00:37
19-year member
UID 72121
Gender Male
Status Offline
: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?
Floor 6 Posted 2006-12-03 02:06 ·  中国 甘肃 张掖 电信
金牌会员
★★★★
Credits 4,103
Posts 1,744
Joined 2006-01-20 13:00
20-year member
UID 49241
Gender Male
From 甘肃.临泽
Status Offline
I'm not a pro~ I made a mistake recently
Floor 7 Posted 2006-12-03 02:24 ·  中国 海南 三亚 电信
新手上路
Credits 16
Posts 7
Joined 2006-12-02 16:07
19-year member
UID 72384
Gender Male
Status Offline
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
借用 lxmxn 头像
莫见怪
Floor 8 Posted 2006-12-03 02:30 ·  中国 四川 泸州 电信
初级用户
Credits 54
Posts 27
Joined 2006-12-02 11:46
19-year member
UID 72370
Gender Male
Status Offline
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!!!
Floor 9 Posted 2006-12-03 03:20 ·  中国 北京 朝阳区 联通
高级用户
★★
朦胧的世界
Credits 579
Posts 218
Joined 2006-10-24 04:29
19-year member
UID 67972
Status Offline

认识自己,降伏自己,改变自己
,才能改变别人!
Floor 10 Posted 2006-12-03 04:17 ·  中国 海南 三亚 电信
新手上路
Credits 16
Posts 7
Joined 2006-12-02 16:07
19-year member
UID 72384
Gender Male
Status Offline
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.
借用 lxmxn 头像
莫见怪
Floor 11 Posted 2006-12-03 04:36 ·  中国 北京 朝阳区 联通
高级用户
★★
朦胧的世界
Credits 579
Posts 218
Joined 2006-10-24 04:29
19-year member
UID 67972
Status Offline
You can use the forum search more!

Click me click me click me

认识自己,降伏自己,改变自己
,才能改变别人!
Floor 12 Posted 2006-12-03 04:51 ·  中国 北京 联通
银牌会员
★★★
努力做坏人
Credits 1,185
Posts 438
Joined 2006-08-28 12:00
19-year member
UID 61449
From 北京
Status Offline
I really don't know why both of you have this picture? Is it just a coincidence?
我今后在论坛的目标就是做个超级坏人!!!
Floor 13 Posted 2006-12-03 05:04 ·  中国 海南 三亚 电信
新手上路
Credits 16
Posts 7
Joined 2006-12-02 16:07
19-year member
UID 72384
Gender Male
Status Offline
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
借用 lxmxn 头像
莫见怪
Floor 14 Posted 2006-12-03 05:54 ·  中国 广西 玉林 博白县 电信
金牌会员
★★★★
Credits 3,687
Posts 1,467
Joined 2005-08-08 12:00
21-year member
UID 44210
Status Offline
The building owner's: sleep 10, unit seconds
5th floor: sleep 10000, unit milliseconds
Floor 15 Posted 2006-12-03 06:07 ·  中国 江苏 苏州 中移铁通
初级用户
★★
Credits 144
Posts 66
Joined 2006-11-30 00:37
19-year member
UID 72121
Gender Male
Status Offline
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~~
Forum Jump: