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-11-24 00:22
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » [Help]Smart batch shutdown Those who are experts come in View 4,924 Replies 19
Floor 16 Posted 2006-12-03 07:01 ·  中国 湖北 武汉 电信
版主
★★★★★
Credits 11,386
Posts 4,938
Joined 2006-07-23 17:10
20-year member
UID 59080
Status Offline

  Re 515808051:

  I don't know if you've tried it or not, and I don't know if it works. The above batch script is written according to what you said in the top post. If it doesn't work, you can tell me where it went wrong, and I'll come and modify it.

  By the way, the above www.cn-dos.com should be changed to www.cn-dos.net. It was a momentary oversight, please forgive us.
Floor 17 Posted 2006-12-03 13:30 ·  中国 海南 三亚 电信
新手上路
★
Credits 16
Posts 7
Joined 2006-12-02 16:07
19-year member
UID 72384
Gender Male
Status Offline
Originally posted by lxmxn at 2006-12-2 06:01 PM:

  Re 515808051:

  I don't know if you've tried it, and I don't know if it works. The above batch script is written according to what you said in the first post. If it doesn't work, you can say which...



Running it, it flashes and nothing happens. Can you explain what it probably means?

If you remove (-n), it shows shutdown...
@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

=====================================
Don't want to trouble everyone anymore. Thanks again. If you can help further, please do your best.
My idea is as follows
According to the original
@echo off
:start
ping 202.100.199.8
if errorlevel 1 goto end
goto start
:end
shutdown -s -t 600
exit

It's to ping XXX.XXX.XXX.XXX randomly. The main thing is that if it pings through, it doesn't execute the next command.
Whether it pings through or not, it has to execute the next command.
Didn't expect that batch processing is more difficult to learn than Adobe Photoshop...

If it's not possible, it's okay. First, I'll look around for relevant posts to study.
借用 lxmxn 头像
莫见怪
Floor 18 Posted 2006-12-03 13:42 ·  中国 湖北 武汉 电信
版主
★★★★★
Credits 11,386
Posts 4,938
Joined 2006-07-23 17:10
20-year member
UID 59080
Status Offline

  Re 515808051 :
  
  Running, it flashes and then disappears, which means the network connection is normal.

  Note that the parameter -n after ping cannot be removed; if removed, an error will occur, so the shutdown dialog box will appear.
Floor 19 Posted 2006-12-04 00:12 ·  中国 海南 三亚 电信
新手上路
★
Credits 16
Posts 7
Joined 2006-12-02 16:07
19-year member
UID 72384
Gender Male
Status Offline
Originally posted by lxmxn at 2006-12-3 12:42 AM:

  Re 515808051 :
  
  Running, flashes and then disappears, which means the network connection is normal.

  Note that the parameter -n after ping cannot be removed; removing it will cause an error...



Thanks a lot. The general meaning is understood a lot.

Flash once and that's it. At worst, find a tool to set the time to run.

Now the network connection is abnormal. Running will shut down. It's the same as what I originally found where the PING consumes too much resources, so it's reduced.

But the problem is still there, which is the automatic shutdown command when the network connection is abnormal.

But when the network connection is normal, it doesn't run and cancel the shutdown command, still the same...

Brother, please work harder and think of a good way.
借用 lxmxn 头像
莫见怪
Floor 20 Posted 2010-04-13 15:47 ·  中国 湖南 衡阳 衡山县 电信
新手上路
★
Credits 2
Posts 2
Joined 2009-08-01 13:08
17-year member
UID 149719
Gender Male
Status Offline
@echo off
:Network Detection
ping XXX.XXX.XXX.XXX
if errorlevel 1 goto end
ping -n 30 localhost > nul
goto Network Detection
:end
shutdown -s -c "Your network is not working, the computer will automatically shut down! http://www.hndnc.com" -t 120

@echo off
:Network Retry
ping -n 10 localhost > nul
ping XXX.XXX.XXX.XXX
if errorlevel 1 goto Network Retry
goto end
:end
shutdown -a
goto Network Detection

1. Detect the network every 30 seconds. When the network is found to be disconnected, it will shut down after a delay of 2 minutes and pop up a prompt box!
2. Within the 2 minutes waiting for shutdown, it will automatically re - detect the network every 10 seconds. If the network is detected to be restored, it will cancel the automatic shutdown and enter the monitoring state of detecting the network every 30 seconds again.
3. The detection frequency and delay time can be modified by yourself.
Forum Jump: