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

When I log into Windows 7 I need to wait 10 seconds and then disable the Local Area Connection (ethernet adaptor) and then reenable it.

I have looked through the suggested answer: Enable/disable wireless interface in a bat file but that seems irrelevant as it just toggles the current state.

From what I can tell I need to include:

netsh interface set interface "Local Area Connection" DISABLED
netsh interface set interface "Local Area Connection" ENABLED

but I'm unsure of the wait time or how I can have this start after Windows has successfully logged in.

What's the best approach here?


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.


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

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

Thanks guys,

I am using this command to disable and enable the problematic WiFi network adapter;

> @echo on
> timeout /t 10
> netsh interface set interface "Wi-Fi" DISABLED
> timeout /t 2
> netsh interface set interface "Wi-Fi" ENABLED