中国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 12:32
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,993 / 19
Floor16 lxmxn Posted 2006-12-03 07:01
版主 Posts 4,938 Credits 11,386

  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.
Floor17 515808051 Posted 2006-12-03 13:30
新手上路 Posts 7 Credits 16
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.
Floor18 lxmxn Posted 2006-12-03 13:42
版主 Posts 4,938 Credits 11,386

  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.
Floor19 515808051 Posted 2006-12-04 00:12
新手上路 Posts 7 Credits 16
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.
Floor20 zhendong Posted 2010-04-13 15:47
新手上路 Posts 2 Credits 2
@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.
Prev  1 2
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023