Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|improve this question
2  
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
1  
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

3 Answers 3

up vote 2 down vote accepted

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.

share|improve this answer
    
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
share|improve this answer
    
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 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
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.