7

My company has recently started giving out HP Elitebooks to employees, replacing the Lenovo ThinkPads we used to use.

I'm trying to find a way to disable the wireless when it detects that an Ethernet connection has been made.

On my ThinkPad this was as easy as going into Access Connections, creating a new location and selecting the box that said 'disable wireless when LAN connection is detected' however on my EliteBook, in HP's equivalent (HP Connection Manager), I'm not seeing that option.

Is there something I'm missing here?

1
  • I wrote something that might help you, I'm working in a scenario where a script wouldn't work and we needed a service that would set itself up and kind of just work, you can find the code here with a packaged installer on the releases page. Good luck.
    – sean_m
    Apr 1, 2016 at 22:59

7 Answers 7

11

If all you are concerned about it using the correct connection, Windows should theoretically prefer the connection with the lowest metric value. Most often, this will be your wired connection. However, if your wired connection is 100 Mbits and your wireless connection is 54Mbits, they will receive the same metric value.

To force the wired connection to a higher priority, you can do the following steps (source, and similar question) (you didn't say, but I'm assuming you have Windows 7 or 8):

  1. Open the "Network and Sharing Center". The easiest way is to right-click on the "Network" icon next to the clock. It will either look like the Wireless signal-strength bars, or like a computer with a cable next to it.
  2. Click "Change Adapter Settings" in the left column.
  3. In the menu bar, click "Advanced", then click "Advanced Settings...". If you do not see the menu bar, press the ALT key on your keyboard to show it.
  4. In the list of available network adapters, click your wired adapter, and use the arrows to move it to the top of the list.

If you actually want to turn off the adapter itself to save battery power, there are several options you can use (source):

  • You can set up "Scheduled Tasks" to turn the wireless on and off when the wired connection is detected.

    1. Find the Event IDs for unplugging and replugging your wired connection. Do this by plugging the cable in and unplugging it again several times, then opening "Event Viewer" (you can type its name in the Start Menu search box) and looking for the generated events in the "System" log. Write down the "Source" and "Event ID" values for these events.
    2. Open "Task Scheduler" (again, you can just type its name in the Start Menu search box), and choose "Create Basic Task".
    3. Follow the instructions for Task creation, inserting the following values when appropriate:
      • Name - "Turn on Wifi"
      • When do you want the task to start? - "When a specific event is logged"
      • Log - "System"
      • Source - Source you found in step 1
      • EventID - Event ID you found above for unplugging Ethernet.
      • Program/script - C:\Windows\System32\Netsh.exe
      • Add arguments - interface set interface "Wireless Network Connection" enable (where "Wireless Network Connection" is the name of your wireless adapter, with the quotes around it)
    4. Create another Basic Task with the following options:
      • Name - "Turn off Wifi"
      • When do you want the task to start? - "When a specific event is logged"
      • Log - "System"
      • Source - Source you found in step 1
      • EventID - Event ID you found above for plugging in Ethernet.
      • Program/script - C:\Windows\System32\Netsh.exe
      • Add arguments - interface set interface "Wireless Network Connection" disable (where "Wireless Network Connection" is the name of your wireless adapter, with the quotes around it)
    5. You may need to change the permissions that the tasks have to run. Otherwise, netsh will say "The requested operation requires elevation (Run as administrator)" and quit. Do these steps for each of the tasks you just created.
      • Right click the task, and choose "Properties"
      • Click "Change User or Group...", type "SYSTEM" in the box, and click OK.
      • Check "Run with highest privileges".
      • Click OK.

    However, this will only work if your laptop generates events when network is plugged in and removed. This will depend on the particular chips and drivers that you have. While using only built-in Windows features is my ideal way to do this, here are two more options if you are unable to use this one.

  • IntelliAdmin has a blog post which describes a VBScript that does exactly what you need. You can download it from the link at the bottom of that post. Download "netswitch.dat" and rename it to "netswitch.vbs". In you start menu put a shortcut that goes to

    cscript LOCATION_OF_netswitch.vbs "WIRED NAME" "WIRELESS NAME".

  • Some people have gotten ThinkVantage Access Connections working on non-Lenovo computers. I am not including a link to download it, because using it in this manner may violate Lenovo's EULA. If you read that license and decide that you think you are compliant, then you can find the download link in my source, above.

3
  • Hey Moshe, thanks for the excellent response I really appreciate it. Turning the adapter is what I want to do, and I tried creating tasks to accomplish this, and while the Netsh program runs right after a LAN connection is detected or disconnected, nothing happens so I'm not really sure what to do from here.
    – wrigley06
    Apr 9, 2014 at 14:35
  • @wrigley06 Are you sure that you got the name of the wireless card correct? I've seen many that call it "Wireless Network Connection", but some just say "Wi-Fi", and others are completely different. You can check the name by opening a Command Prompt (cmd.exe) and typing netsh interface show interface.
    – Moshe Katz
    Apr 9, 2014 at 17:43
  • @wrigley06 You may also need to change what user the task runs as. By default, the task probably runs as you, but only an administrator can enable/disable network interfaces. I have updated the answer with details - see step 5.
    – Moshe Katz
    Apr 9, 2014 at 18:00
8

HP EliteBook laptops have a built-in ability to disable the wireless connection when an Ethernet cable is plugged in. It's called "LAN/WLAN switching" and can be toggled in the BIOS/UEFI setup.

The exact steps you need to take might vary depending on your EliteBook model, but on my 6930p the following works:

  1. Press F10 during boot to go to BIOS/UEFI setup.
  2. Go to System Configuration → Built-In Device Options
  3. Find the "LAN/WLAN Switching" option and select the "Enabled" radio button next to it
  4. Save changes and exit BIOS/UEFI setup to reboot

That should do the trick. If you have a different model (especially if it's from a different generation), consult the model's user manual.

Note that if you're using HP's ProtectTools software and have the BIOS Configuration add-on installed, then you should also be able to toggle this setting from within Windows, but you'll still have to reboot for it to take effect.

2
  • does a dell e5570 has the same?
    – roel
    Nov 23, 2016 at 7:39
  • @roel Sorry, no idea. If you have that laptop, check the BIOS/UEFI settings. Alternatively, consult the manual.
    – Indrek
    Nov 23, 2016 at 8:19
2

Alternate PowerShell solution: https://gallery.technet.microsoft.com/scriptcenter/WLAN-Manager-f438a4d7

WLAN Manager runs as a scheduled task and will automatically disable your WLAN card when a LAN connection is verified. The WLAN card will be re-enabled once the LAN connection is lost. This ensures you'll have the fastest available connection and helps prevent network bridging.

Original code by "substance" at Microsoft Technet. Zip file

################ 
# WLAN Manager # 
################ 
#Version: 2015-03-03.2 
#Author: [email protected] 

<# 

.SYNOPSIS 
Disables the WLAN NIC when LAN NIC network connection is verified. 
Enables WLAN NIC when LAN NIC network connection is lost. 

.DESCRIPTION 
WLAN Manager runs as a scheduled task and will automatically disable your WLAN card when a LAN connection is verified. 
The WLAN card will be re-enabled once the LAN connection is lost. This ensures you'll always have the fastest available connection and stops network bridging. 

.EXAMPLE 
.\WLANManager.ps1 -Install:$true 
Installs WLAN Manager. 

.EXAMPLE 
.\WLANManager.ps1 -Remove:$true 
Removes WLAN Manager. 

.EXAMPLE 
.\WLANManager.ps1 
Verify Installaton > Install if missing > Run Interactively (first run only, hidden run via scheduled task run after that). 

.EXAMPLE 
.\WLANManager.ps1 -Interactive:$true 
Runs WLAN Manager in an interactive window. Will not install anything. This mode is only for testing and watching what happens via console output. 

.NOTES 
None. 

.LINK 
https://support.innovatum.se 

#> 

[CmdletBinding()] 
Param 
( 
    [Parameter(Mandatory=$False,Position=1,HelpMessage="Installs WLAN Manager.")] 
    [switch]$Install, 
    [Parameter(Mandatory=$False,Position=2,HelpMessage="Removes WLAN Manager.")] 
    [switch]$Remove, 
    [Parameter(Mandatory=$False,Position=3,HelpMessage="Runs WLAN Manager interactively, doesn't install anything.")] 
    [switch]$Interactive 
) 

######################################### 
# Custom Variables for Your Environment # 
######################################### 
#Destination Path to where you want to store files for local install of WLANManager 
$CustomDestinationPath = "$env:ProgramFiles\WLANManager" 


<# 
D O   N O T   C H A N G E   A N Y T H I N G   B E L O W   T H I S   L I N E 
#> 


################################# 
# Unload/Load PowerShell Module # 
################################# 

#Remove PowerShell Module 
If ((Get-Module PSModule-WLANManager) -ne $null) 
    { 
        Remove-Module PSModule-WLANManager -Verbose 
    } 

#Import PowerShell Module 
$strBasePath = Split-Path -Path $MyInvocation.InvocationName 
Import-Module "$strBasePath\PSModule-WLANManager.psm1" -Verbose 


############################# 
# Install or Update Install # 
############################# 

If ($Remove -eq $true) 
    { 
        Remove-WLANManager -FilePath $CustomDestinationPath 
        return 
    } 
ElseIf ((Test-Path -Path $strBasePath) -eq $True -and ($Interactive) -ne $true) 
    { 
        #Install 
        Install-WLANManager -SourcePath $strBasePath -DestinationPath $CustomDestinationPath 
        If ($Install -eq $true) 
            { 
                #≥Windows 8 
                If ($OSInfo.Caption -match "Windows 8") 
                    { 
                        Start-ScheduledTask -TaskName "WLAN Manager" 
                        Exit 
                    } 
                #<Windows 8 
                Else 
                    { 
                        Start-STask -TaskName "WLAN Manager" | Out-Null 
                        Exit 
                    } 
            } 
    } 


######## 
# Main # 
######## 

while ($true) 
{ 
    If ((Test-WiredConnection) -eq $true -and (Test-WirelessConnection) -eq $true) 
        { 
            Write-Host "Wired connection detected, disabling Wireless connection... " -NoNewline -ForegroundColor Yellow 
            #≥Windows 8 
            If ($OSInfo.Caption -match "Windows 8") 
                { 
                    Disable-NetAdapter -InterfaceDescription *Wireless* -Confirm:$false 
                } 
            #<Windows 8 
            Else 
                { 
                    Disable-WLANAdapter | Out-Null 
                } 
            Write-Host "Done" -ForegroundColor White -BackgroundColor Green 
        } 

    If ((Test-WiredConnection) -eq $false -and (Test-WirelessConnection) -eq $false) 
        { 
            Write-Host "Wired connection lost, enabling Wireless connection... " -NoNewline -ForegroundColor Yellow 
            #≥Windows 8 
            If ($OSInfo.Caption -match "Windows 8") 
                { 
                    Enable-NetAdapter -InterfaceDescription *Wireless* -Confirm:$false 
                } 
            #<Windows 8 
            Else 
                { 
                    Enable-WLANAdapter | Out-Null 
                } 
            #Wait for WLAN Adapter to initialize and obtain an IP-address 
            while ((Test-WiredConnection) -eq $false -and (Test-WirelessConnection) -eq $false) 
                { 
                    sleep -Seconds 1 
                } 
            Write-Host "Done" -ForegroundColor White -BackgroundColor Green 
        } 

    Else 
        { 
            Write-Host "Sleeping..." -ForegroundColor Yellow 
            sleep -Seconds 1 
        } 
} 
2
  • Hi Johan, @tog expanded the answer to meet requirements, as it stands now (again) it will likely be deletes. Link-only answers can become invalid if the linked page changes. Please take a look here: Why and how are some answers deleted?
    – bummi
    Mar 11, 2015 at 14:10
  • Can you explain why you reversed the edit expanding the answer?
    – bwDraco
    Mar 12, 2015 at 7:19
0

I came up with a custom solution with the help of Moshe Katz answer (thanks Moshe Katz!) which works well for my 100 laptops.

Save the following text as wifiswitch.bat file under C:\windows\system32. Make sure to check the interface names on the laptop matches the scripts:

            @echo off
            Title Wifi Lan Switcher

            set a=0

            :loop
            netsh interface show interface name="Local Area Connection" | find /i "disconnected" > NUL 2>&1
            IF ERRORLEVEL 1 (
                netsh interface show interface name="Wireless Network Connection" | find /i "disabled" > NUL 2>&1
                IF ERRORLEVEL 1 (
                    netsh interface set interface name="Wireless Network Connection" disable > NUL 2>&1
                    set error=%errorlevel%
                    ping -n 5 127.0.0.1 >nul
                )
            ) 
            netsh interface show interface name="Local Area Connection" | find /i "disconnected" > NUL 2>&1
            IF NOT ERRORLEVEL 1 (
                netsh interface show interface name="Wireless Network Connection" | find /i "enabled" > NUL 2>&1
                    IF ERRORLEVEL 1 (
                        netsh interface set interface name="Wireless Network Connection" enable > NUL 2>&1
                        set error=%errorlevel%
                        ping -n 5 127.0.0.1 >nul
                    )
            )

            set /a a+=1

            echo.
            echo %a%
            ping -n 3 127.0.0.1 >nul
            if %a% equ 5 goto :eof
            goto :loop

            :eof
            echo.
            echo.
            set a=
            exit /b %error%

Now, you will need to create one task under scheduled tasks. You can save my task xml code in .xml and and then import it to a laptop's task scheduler. Make sure to change the source under Triggers tab to the one that belongs to your specific model:

            <?xml version="1.0" encoding="UTF-16"?>
            <Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
              <RegistrationInfo>
                <Date>2014-07-07T09:36:51.4300545</Date>
                <Author>%username%</Author>
              </RegistrationInfo>
              <Triggers>
                <EventTrigger>
                  <Enabled>true</Enabled>
                  <Subscription>&lt;QueryList&gt;&lt;Query Id="0" Path="System"&gt;&lt;Select Path="System"&gt;*[System[Provider[@Name='e1cexpress']]]&lt;/Select&gt;&lt;/Query&gt;&lt;/QueryList&gt;</Subscription>
                </EventTrigger>
                <BootTrigger>
                  <Enabled>true</Enabled>
                  <Delay>PT1M</Delay>
                </BootTrigger>
                <RegistrationTrigger>
                  <Enabled>true</Enabled>
                </RegistrationTrigger>
              </Triggers>
              <Principals>
                <Principal id="Author">
                  <UserId>S-1-5-18</UserId>
                  <RunLevel>HighestAvailable</RunLevel>
                </Principal>
              </Principals>
              <Settings>
                <MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>
                <DisallowStartIfOnBatteries>false</DisallowStartIfOnBatteries>
                <StopIfGoingOnBatteries>true</StopIfGoingOnBatteries>
                <AllowHardTerminate>true</AllowHardTerminate>
                <StartWhenAvailable>true</StartWhenAvailable>
                <RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable>
                <IdleSettings>
                  <StopOnIdleEnd>true</StopOnIdleEnd>
                  <RestartOnIdle>false</RestartOnIdle>
                </IdleSettings>
                <AllowStartOnDemand>true</AllowStartOnDemand>
                <Enabled>true</Enabled>
                <Hidden>false</Hidden>
                <RunOnlyIfIdle>false</RunOnlyIfIdle>
                <WakeToRun>false</WakeToRun>
                <ExecutionTimeLimit>PT1H</ExecutionTimeLimit>
                <Priority>7</Priority>
                <RestartOnFailure>
                  <Interval>PT1M</Interval>
                  <Count>3</Count>
                </RestartOnFailure>
              </Settings>
              <Actions Context="Author">
                <Exec>
                  <Command>%windir%\System32\WifiSwitch.bat</Command>
                  <WorkingDirectory>%windir%\system32</WorkingDirectory>
                </Exec>
              </Actions>
            </Task>
0

Press F2 on boot to get into the Bios. Go to Power Management Select Wireless Radio Control Enable Control WLAN radio and Control WWAN radio

If Enabled, this feature will sense the connection of the system to a wired network and subsequently disable the selected wireless radios (WLAN and/or WWAN). Upon disconnection from the wired network, the selected wireless radios will be re-enabled.

0

If you have the driver for the Ethernet, i.e., I use fast Ethernet controller for my Samsung laptop, then on the task bar at the right most corner:

  1. click the Ethernet icon, which is possibly just an E usually yellow like
  2. then on the pop up window click Connection Manager
  3. then Options
  4. on option then check/tick the check box for disable the wireless radio while the Ethernet adapter is available

Result: whenever you connect your Ethernet cable the wireless connection will be disabled giving priority to the Ethernet connection.

1
  • 1
    This is poorly written, but it is a correct solution in Windows 10, and does not duplicate any existing answer. Sep 7, 2017 at 16:10
0

Something to note about this. We have HP laptops and they have a BIOS setting to do this. We found out remote users would connect to the VPN and it would set up a cabled network adapter and disable the wifi. So when they were home on the couch or at a coffee shop they would get disconnected.
We are using the Watchguard Mobile SSL VPN client software.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .