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?

-
Why do you need to wait 10 seconds, disable the LAN and then re-enable it? –  That Brazilian Guy Dec 18 '12 at 1:51
Tell us the underlying problem, it may be more sensible to solve that than to mess with interface. –  Paul Dec 18 '12 at 2:42
I use 2 x TL-PA211 EOP adaptors (www.tp-link.com/en/products/details/?model=TL-PA211) to connect to my home modem/router. The issue is that whenever I boot up my machine, my ethernet adaptor does not automatically connect, instead I see the following: - i.imgur.com/weFHV.jpg – it tells me that I am connected to my usual home network plus an Unidentified network. I then have to disable my ethernet adaptor and reenable it and then it connects to my usual home network - every time I turn the computer on. I am using the TL-PA2111 pairing application and my Ethernet drivers are up to date. –  rlsaj Dec 18 '12 at 3:50

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.

-
Perfect, thanks David. –  rlsaj Dec 20 '12 at 21:16

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

-
Upvoted because it's just, what I was looking for, I needed a 2 sec delay between the on and off and no initial, for when sometimes my card refuses to get a connection on startup, so I have a handy bat file on the desktop –  Limiter Aug 1 '14 at 16:24

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

-