Windows 7 Script for turning lan connection on/off

Discussion in 'Programming and Scripting' started by MrLH, Jul 25, 2013.

  1. MrLH

    MrLH New Member

    Joined:
    Mar 5, 2013
    Messages:
    17
    Likes Received:
    1
    I had this wonderful script that I got from someplace (can't recall) that enabled or disabled lan connections in windows xp. I used it to turn the wireless card on/off as the card made clicking noises during recording/playback of music files. I have just performed a clean install of windows 7 and am migrating backed up files and programs but can't find the script anywhere in my backup. Does anyone know of such a script and can it be used in windows 7? I'd hate to have to hop through several screens everytime I want to turn it off/on and think there must be a simpler way to get it done. Any ideas or places to direct my attention to?
     
  2. Mike

    Mike Windows Forum Admin
    Staff Member Premium Supporter

    Joined:
    Jul 22, 2005
    Messages:
    8,488
    Likes Received:
    783
    Start elevated Command Prompt.

    Get NIC list and index number:
    wmic nic get name, index

    Enable NIC with index number: (eg: 7)
    wmic path win32_networkadapter where index=7 call enable

    Disable NIC with index number: (eg: 7)
    wmic path win32_networkadapter where index=7 call disable

    Result:
    wmic path win32_networkadapter where NetConnectionID="Wireless Network Connection" call disable
    wmic path win32_networkadapter where NetConnectionID="Wireless Network Connection" call enable

    Create two shortcuts, run as elevated.
    A further answer about this can be found here: http://answers.microsoft.com/en-us/windows/forum/windows_7-hardware/enabledisable-network-interface-via-command-line/17a21634-c5dd-4038-bc0a-d739209f5081
     
    Uche and Trouble like this.
  3. Josephur

    Josephur Windows Forum Admin
    Staff Member Premium Supporter

    Joined:
    Aug 3, 2010
    Messages:
    1,019
    Likes Received:
    125
    Can also use

    netsh interface set interface "Wireless Network Connection" enabled
    netsh interface set interface "Wireless Network Connection" disabled

    Don't forget to replace the name of "Wireless Network Connection" with the name of your connection as found in Network Connections.
     
    Mike likes this.
  4. MrLH

    MrLH New Member

    Joined:
    Mar 5, 2013
    Messages:
    17
    Likes Received:
    1
    Thanks guys, sorry it took so long to get back to you but have been extremely busy. I have been able to get it done and both suggestions work fine. These are incredibly easy to employ, the script I had was a VB script and had lots of lines, stuff I could never remember if my life depended on it but it worked as a stand alone item. I don't mind a turn on icon and a turn off icon though, it gets the job done. Thanks again!
     
    Mike likes this.
  5. Uche

    Uche New Member

    Joined:
    Sep 25, 2013
    Messages:
    3
    Likes Received:
    0
    Here i face a different challenge still with wlan.
    My wlan and Bluetooth swiches are powered by a touch sensor.
    The Flex cable connecting this touch panel went bad so i cannot turn on the wlan and Btooth hardware.

    How can i work around this till i replace the flex cable.
     
  6. Josephur

    Josephur Windows Forum Admin
    Staff Member Premium Supporter

    Joined:
    Aug 3, 2010
    Messages:
    1,019
    Likes Received:
    125
    Chances are you will not be able to do this, unless your BIOS supports disabling this switch all together somehow. What model of laptop (I'm assuming) uses a touch sensor for turning radio on/off ??
     
  7. Uche

    Uche New Member

    Joined:
    Sep 25, 2013
    Messages:
    3
    Likes Received:
    0
    I am using an MSI EX620 laptop.
     
  8. Josephur

    Josephur Windows Forum Admin
    Staff Member Premium Supporter

    Joined:
    Aug 3, 2010
    Messages:
    1,019
    Likes Received:
    125
    Is there a Function-F8 key combo that might work?
     
    Uche likes this.
  9. Uche

    Uche New Member

    Joined:
    Sep 25, 2013
    Messages:
    3
    Likes Received:
    0
    My FnF8 is for increasing volume
     

Share This Page

Loading...