Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use batch command in windows host to check the network card network automatically restart the network card

2025-04-10 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly shows you the "windows host how to use batch commands to check the network card network automatic restart network card", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "windows host how to use batch commands to check the network card network automatic restart network card" this article.

Cause analysis and treatment:

1. Is it possible that the ip of the server host has been overturned? This may be there, but it should be relatively small.

two。 System vulnerabilities lead to?

Therefore, the system vulnerability has been updated.

3. Hardware driver problem?

Download the network card driver again and reinstall it.

4. There is a hardware problem with the network card, so we can only replace the network card. It's impossible to tell yet.

In view of the possibility of network disconnection, to this end, sort out a section of code to check the situation of the network, the network cannot be connected, and the network card can be restarted automatically.

The code is as follows, for reference only:

@ echo off

Echo "Network card automatic check restart service is in progress."

Echo "Please press Ctrl+C to stop service"

: begin

Set "year=%date:~0,4%"

Set "month=%date:~5,2%"

Set "day=%date:~8,2%"

Echo date% time% "ping." > > ping%year%%month%%day%.txt

Ping 192.168.1.1 > > ping%year%%month%%day%.txt

Rem echo errorlevel%

If% ERRORLEVEL% = = 1 goto reboot

Goto loop

: reboot

Echo date% time% Network Card restarted > > errlog.log

Echo% date%% time% "Network card is being deactivated."

Netsh interface set interface "Local connection 2" disabled

Echo% date%% time% "Network card booting...."

Netsh interface set interface "Local connection 2" enabled

Echo% date%% time% "Nic has been restarted."

: loop

Ping 127.0.0.1-n 60 > nul

Goto begin

Description:

Rem indicates that the character after this command is an interpretation line, which is not executed, but is only used for future search. :: can also play the role of rem annotation, and more concise and effective

% errorlevel% returns the result of the last command execution that was unsuccessful and returned as 1 successfully returned as 0

When using the if% errorlevel%== value cmmand sentence, it means that if the returned error code value is equal to the value, the cmmand operation will be performed.

Netsh interface set interface "Local connection 2" enabled

This local connection 2 can be replaced with a network card, such as internet

The above is all the contents of the article "how to use batch commands in windows hosts to check the network card network automatically restart the network card". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report