bat file to disable ethernet adaptor and then reenable it after windows log in

I hope this helps

@echo on
timeout /t 10
netsh interface set interface "Local Area Connection" DISABLED
timeout /t 10
netsh interface set interface "Local Area Connection" ENABLED

Create a Windows Scheduled Task (taskschd.msc or Control Panel\System and Security\Administrative Tools\Task Scheduler) with a Trigger: begin the task At log on and in the Advanced settings delay task for 30 seconds. Then add an Action to Start a program and select your .bat script.


The logic is: ping public ip (google dns 8.8.8.8), if the ping fails, then goto :RESTART and restart network adapter with name "LAN", after this loop again from the start (if ping is OK, then do nothing and ping in loop to check if adapter is connected to internet)

   @echo off 

    :LOOP
    ping 8.8.8.8
    IF ERRORLEVEL 1 goto RESTART
    IF ERRORLEVEL 0 goto LOOP
    :RESTART
    netsh interface set interface "LAN" disabled
    ping -n 3 127.0.0.1
    netsh interface set interface "LAN" enabled
    ping -n 15 127.0.0.1
    goto LOOP