中国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:45
47,811 topics / 349,897 posts / today 0 new / 48,256 members
DOS批处理 & 脚本技术(批处理室) » Batch processing to detect network status, automatically restart the computer when the network is not working
Printable Version  1,573 / 13
Floor1 lianruidong Posted 2009-09-09 06:17
新手上路 Posts 10 Credits 10
As the title.

If the network is detected to be unavailable, the computer will automatically restart after 5 minutes.

Thank you
Floor2 szweiw Posted 2009-09-09 06:34
新手上路 Posts 18 Credits 18
```
:start
::Change this IP to the address you use to detect the network, such as the gateway
ping 10.10.37.254 -n 1 > nul
::-t The number behind is how many seconds to wait before restarting
if %errorlevel% neq 0 shutdown -r -t 300
goto :start
```
Floor3 lianruidong Posted 2009-09-09 07:29
新手上路 Posts 10 Credits 10
Thanks, I just tried it, it's quite good.

Add another question, is there a command that can repair the network connection?

My idea is like this: The server itself has been running this P. When it is found that the network is not working, it will automatically repair the network. After the repair is completed, it will automatically restart the computer. I mainly want the server to repair itself. Thanks
Floor4 szweiw Posted 2009-09-09 10:39
新手上路 Posts 18 Credits 18
There are many reasons for network disconnection... If this could be done automatically, a large number of network administrators would be out of work
Floor5 szweiw Posted 2009-09-09 13:13
新手上路 Posts 18 Credits 18
After thinking about it, the code provided earlier is still not good enough. After losing network connection, it will keep executing shutdown. We should set up to jump out of the loop.

Floor6 lianruidong Posted 2009-09-09 22:50
新手上路 Posts 10 Credits 10
Thanks! You this one restarts as soon as it doesn't work. If the network flashes and breaks when it's just PINGing, that's not good, right? I think it should restart the computer when PING has been uninterrupted for 2 minutes, can that work?
Floor7 yishanju Posted 2009-09-09 23:06
银牌会员 Posts 1,357 Credits 1,488
This method is obviously not a way to ensure server stability and network stability.
Floor8 lianruidong Posted 2009-09-10 02:31
新手上路 Posts 10 Credits 10
But the company doesn't want to buy equipment, so we have to make a simple one by ourselves.
Floor9 lianruidong Posted 2009-09-10 02:33
新手上路 Posts 10 Credits 10
This is what I thought. If the above assumption is solved, then I will find a short message sending device. If the network is still not working after restarting the computer, it will automatically send a short message "XX server network interruption". Is it feasible?
Floor10 yishanju Posted 2009-09-10 02:51
银牌会员 Posts 1,357 Credits 1,488
Originally posted by lianruidong at 2009-9-10 02:33:
This is what I thought.
If the above assumption is solved,
I will find a short message sending device, and if the network is still not working after restarting the computer, it will automatically send a short message "XX server network is interrupted".
Is it feasible?


It is to use the interface of Feixin to send free short messages.

Feixin message sending program http://www.cn-dos.net/forum/viewthread.php?tid=48736&fpage=1&highlight=
Floor11 lianruidong Posted 2009-09-10 04:18
新手上路 Posts 10 Credits 10
Thank you
I'll try it!
Floor12 lianruidong Posted 2009-09-10 05:20
新手上路 Posts 10 Credits 10
Originally posted by szweiw at 2009-9-9 13:13:
Thought about it, the code given just now is still not good enough. After losing internet connection, it will keep executing shutdown. Still, the loop should be set to break out

Floor13 lianruidong Posted 2009-09-10 05:21
新手上路 Posts 10 Credits 10
Originally posted by yishanju at 2009-9-10 02:51:

It's just using the Feixin interface to send text messages for free

Feixin message sending program http://www.cn-dos.net/forum/viewthread.php?tid=48736&fpage=1&highlight=

Thanks
I have tested and it was successful
Floor14 lianruidong Posted 2009-09-10 05:23
新手上路 Posts 10 Credits 10
Hello!
Can this be done? First ping a machine, if it's not reachable, then continue pinging for 1 minute. If it's still not reachable, then restart the computer, and it's not a dead loop, thank you!
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023