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 12:29
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » Batch processing to detect network status, automatically restart the computer when the network is not working View 1,575 Replies 13
Original Poster Posted 2009-09-09 06:17 ·  中国 北京 鹏博士BGP
新手上路
Credits 10
Posts 10
Joined 2009-09-07 06:26
16-year member
UID 151609
Gender Male
Status Offline
As the title.

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

Thank you
Floor 2 Posted 2009-09-09 06:34 ·  中国 广东 广州 天河区 电信
新手上路
Credits 18
Posts 18
Joined 2009-07-27 08:53
17-year member
UID 149450
Gender Male
Status Offline
```
: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
```
Floor 3 Posted 2009-09-09 07:29 ·  中国 北京 鹏博士BGP
新手上路
Credits 10
Posts 10
Joined 2009-09-07 06:26
16-year member
UID 151609
Gender Male
Status Offline
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
Floor 4 Posted 2009-09-09 10:39 ·  中国 广东 广州 天河区 电信
新手上路
Credits 18
Posts 18
Joined 2009-07-27 08:53
17-year member
UID 149450
Gender Male
Status Offline
There are many reasons for network disconnection... If this could be done automatically, a large number of network administrators would be out of work
Floor 5 Posted 2009-09-09 13:13 ·  中国 广东 广州 天河区 电信
新手上路
Credits 18
Posts 18
Joined 2009-07-27 08:53
17-year member
UID 149450
Gender Male
Status Offline
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.


:start
ping 10.10.37.254 -n 1 > nul
if %errorlevel% neq 0 (
shutdown -r -t 300
goto :end
)
goto :start

:end
Floor 6 Posted 2009-09-09 22:50 ·  中国 北京 鹏博士BGP
新手上路
Credits 10
Posts 10
Joined 2009-09-07 06:26
16-year member
UID 151609
Gender Male
Status Offline
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?
Floor 7 Posted 2009-09-09 23:06 ·  中国 北京 西城区 联通
银牌会员
★★★★
[b]看你妹啊[/b]
Credits 1,488
Posts 1,357
Joined 2006-05-20 12:00
20-year member
UID 55770
Status Offline
This method is obviously not a way to ensure server stability and network stability.

有问题请发论坛或者自行搜索,再短消息问我的统统是SB
Floor 8 Posted 2009-09-10 02:31 ·  中国 北京 鹏博士BGP
新手上路
Credits 10
Posts 10
Joined 2009-09-07 06:26
16-year member
UID 151609
Gender Male
Status Offline
But the company doesn't want to buy equipment, so we have to make a simple one by ourselves.
Floor 9 Posted 2009-09-10 02:33 ·  中国 北京 鹏博士BGP
新手上路
Credits 10
Posts 10
Joined 2009-09-07 06:26
16-year member
UID 151609
Gender Male
Status Offline
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?
Floor 10 Posted 2009-09-10 02:51 ·  中国 北京 西城区 联通
银牌会员
★★★★
[b]看你妹啊[/b]
Credits 1,488
Posts 1,357
Joined 2006-05-20 12:00
20-year member
UID 55770
Status Offline
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=

有问题请发论坛或者自行搜索,再短消息问我的统统是SB
Floor 11 Posted 2009-09-10 04:18 ·  中国 北京 鹏博士BGP
新手上路
Credits 10
Posts 10
Joined 2009-09-07 06:26
16-year member
UID 151609
Gender Male
Status Offline
Thank you
I'll try it!
Floor 12 Posted 2009-09-10 05:20 ·  中国 北京 鹏博士BGP
新手上路
Credits 10
Posts 10
Joined 2009-09-07 06:26
16-year member
UID 151609
Gender Male
Status Offline
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


:start
ping 10.10.37.254 -n 1 > nul
if %errorlevel% neq 0 (
...

Sorry
Tried it, but it's still an infinite loop
Floor 13 Posted 2009-09-10 05:21 ·  中国 北京 鹏博士BGP
新手上路
Credits 10
Posts 10
Joined 2009-09-07 06:26
16-year member
UID 151609
Gender Male
Status Offline
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
Floor 14 Posted 2009-09-10 05:23 ·  中国 北京 鹏博士BGP
新手上路
Credits 10
Posts 10
Joined 2009-09-07 06:26
16-year member
UID 151609
Gender Male
Status Offline
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!
Forum Jump: