Disable wireless when ethernet connection is detected on an HP EliteBook
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):
- 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.
- Click "Change Adapter Settings" in the left column.
- 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.
- 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.
- 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.
- Open "Task Scheduler" (again, you can just type its name in the Start Menu search box), and choose "Create Basic Task".
- 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)
- 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)
- 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.
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:
- Press F10 during boot to go to BIOS/UEFI setup.
- Go to System Configuration → Built-In Device Options
- Find the "LAN/WLAN Switching" option and select the "Enabled" radio button next to it
- 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.
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
}
}