L
L
ligerium2020-07-20 13:54:53
Automation
ligerium, 2020-07-20 13:54:53

How to make an ethernet network connection automatically restart when there is no internet?

Greetings. It's not the first day I've been fighting with automation, the task is to restart the Internet adapter over the wire.
I tried to release .bat through a ping check and a command to turn off and turn on the adapter, but he carried out a ping check until I pulled out the wire myself, or changed the provider's poppy to create a shutdown situation. the batnik was closed. although he had to restart the adapter until the Internet turned on, that is, check the ping and until he responded to restart the adapter. Knowledgeable people, help solve the problem.

@echo off
:LOOP
ping 8.8.8.8 -n 2
if errorlevel 1 (
echo %Errorlevel%
echo %date% %time% >> C:\log.txt
netsh interface set interface name="Ethernet" DISABLE
netsh interface set interface name="Ethernet" ENABLE
exit
) ELSE (
echo
)
timeout /T 30
goto

LOOP

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Artem @Jump, 2020-07-21
curated by the

Create a task in the Task Scheduler that will run at regular intervals.
For example, once every five minutes, or once every half an hour.
Call the batch file, it pings the resource, and if there is no ping, it reboots the adapter.

A
Anton, 2020-10-18
@InfinityMe

Normal routers like Keenetic can do this.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question