7

Image: Wi-Fi Toggle button in Windows 10

If I try to connect to a wireless network using netsh wlan connect when the Wi-Fi toggle switch is off, the following error is displayed:

Function WlanGetAvailableNetworkList returns error 2150899714:

The wireless local area network interface is powered down and doesn't support the requested operation.

I've tried re-enabling the wireless interface using netsh int set int, but that didn't seem to re-toggle the Wi-Fi button. How do I connect to a wireless network via the command line if the Wi-Fi toggled switch is disabled? I suspect the similar problem occurred with a laptop–that had a corrupted Windows 10 upgrade, which led to explorer.exe not working–when I tried to connect it to the Wi-Fi.

The network interface has already been enabled, so that isn't the problem. It seems separate from the Wi-Fi toggle switch.

For future readers: The currently marked answer is very good, but requires the Settings app to be functioning. This may not always in crippled installs (happened in a corrupt Windows 10 update), where only the command prompt is functioning. Please add a new answer if a command-prompt-only method is made available.

Note: This question is not a duplicate of Can't enable "Wi-Fi" interface via command line (Windows 10). That question relates to a specific error message (which appears to be a bug unrelated to this issue). This question was created as a follow up to the more specific problem of toggling the Wi-Fi button in Windows 10 via cmd.

1
  • @WeavingBird1917 It needs to be done in two steps. First you need to enable network adapter and then you can connect to wifi. Here you can find commands to enable/disable network adapter (see answer posted by abzcoding. After enabling wlan adapter try connecting netsh wlan connect.
    – Sandeep
    Jun 15, 2018 at 14:02

1 Answer 1

4

Below is a batch script that will toggle the state of Wi-Fi either ON or OFF to the opposite state it in when it runs. This uses ms-settings:network-wifi to open the Wi-Fi Settings screen, and then it presses the space key one time using sendkeys to toggle. This method builds a dynamic vb script with a batch script and then executes the vb script with cscript to emulate pressing the space key.

GUI Toggle

enter image description here


Script

Note: Just save this to a text file with a .bat or .cmd extension and execute it to run.

@ECHO OFF

explorer ms-settings:network-wifi
ping -n 5 127.0.0.1 > nul

:VBSDynamicBuild
SET TempVBSFile=%tmp%\~tmpSendKeysTemp.vbs
IF EXIST "%TempVBSFile%" DEL /F /Q "%TempVBSFile%"
ECHO Set WshShell = WScript.CreateObject("WScript.Shell") >>"%TempVBSFile%"
ECHO Wscript.Sleep 500                                    >>"%TempVBSFile%"
ECHO WshShell.SendKeys " "                                >>"%TempVBSFile%"
ECHO Wscript.Sleep 500                                    >>"%TempVBSFile%"

CSCRIPT //nologo "%TempVBSFile%"
EXIT


Further Resources

1
  • @WeavingBird1917 You can add NETSH WLAN CONNECT SSID=<SSID> NAME=<WLAN Profile Name> to the bottom of the script (just above the EXIT)—and I'll edit to add as an example if needed once I hear back from you if this method will suffice to turn ON the wi-fi and then connect to it via NETSH afterwards Jun 16, 2018 at 1:05

You must log in to answer this question.