I'm searching for a way to enable/disable the Hotspot built into Windows 10 via the command prompt, powershell or a batch file. In the GUI, it can be easily done with the third button in the network panel (see image below), but I want to automate it.
I already found some hundred tutorials how to create a new hotspot using netsh
, but as I understand it this would create another, different hotspot.
Instead I want to use the already configured one. Or does Windows 10 use the same and creates a new hotspot every time but in between only remembers the settings?
I played around a little bit and discovered the following:
netsh wlan show drivers
it says hosted network supprt: no
. So for the 'common' solution I would have to update the driver.Microsoft Wi-Fi Direct Virtual Adapter #x
. As soon I deactivate the HotSpot, the adapter vanishes.So it seems that MS is using a very different technique for the built-in hotspot than the netsh
variant. Which brings me again to the question: how can I automate (by script) the enabling/disabling of this hotspot?
Select the Start button, then select Settings > Network & Internet > Mobile hotspot. For Share my Internet connection from, choose the Internet connection you want to share. Select Edit > enter a new network name and password > Save. Turn on Share my Internet connection with other devices.
While in Command Prompt (Admin) enter the following command: NETSH WLAN set hostednetwork mode=allow ssid=Your_SSID key=Your_Passphrase Where the SSID would be the name you want to identify your wireless network when trying to connect a new device, and the passphrase is the network security key you want users to use to ...
Open Settings by pressing Win + X keys and choosing Settings on the menu. In Settings, go to Network & Internet > Mobile hotspot. Make sure that your mobile hotspot is on. Then, click Change adapter options under the Related Settings.
The Hosted Network (which can be configured using the netsh wlan set hostednetwork ...
command) and the "new" Mobile Hotspot use different technologies under the hood.
There's a WinRT API to control and configure the "new" mobile hotspot you're referring to. You can call it from PowerShell:
The following code snippet requires Ben N.'s await function for IAsyncOperation and IAsyncAction in PowerShell, which can be found here.
$connectionProfile = [Windows.Networking.Connectivity.NetworkInformation,Windows.Networking.Connectivity,ContentType=WindowsRuntime]::GetInternetConnectionProfile()
$tetheringManager = [Windows.Networking.NetworkOperators.NetworkOperatorTetheringManager,Windows.Networking.NetworkOperators,ContentType=WindowsRuntime]::CreateFromConnectionProfile($connectionProfile)
# Be sure to include Ben N.'s await for IAsyncOperation:
# https://superuser.com/questions/1341997/using-a-uwp-api-namespace-in-powershell
# Check whether Mobile Hotspot is enabled
$tetheringManager.TetheringOperationalState
# Start Mobile Hotspot
Await ($tetheringManager.StartTetheringAsync()) ([Windows.Networking.NetworkOperators.NetworkOperatorTetheringOperationResult])
# Stop Mobile Hotspot
Await ($tetheringManager.StopTetheringAsync()) ([Windows.Networking.NetworkOperators.NetworkOperatorTetheringOperationResult])
The NetworkOperatorTetheringManager class also allows you to set the SSID and the passphrase of your hotspot programmatically.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With