Share via

How do I start hotspot through Command Prompt?

Anonymous
2023-05-13T01:51:58+00:00

Hello,

I am currently trying to make a batch file on my PC that automatically turns on the hotspot when I log in. I am using the following command:

netsh wlan start hostednetwork //start hotspot

...and repeatedly recieve the following error message:

The hosted network couldn't be started.

The group or resource is not in the correct state to perform the requested operation.

I am doing this in an elevated Command Prompt window using version 10.0.22621.1702. I have tried solutions from other forums, including those on Microsoft forums. This is an example of what I have tried, but it did not solve my problem. It led to the same error message. Does anybody know another fix, or another method of turning on the Windows 11 hotspot on login (preferably on system startup)?

Windows for home | Windows 11 | Performance and system failures

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

  1. Paulo GM 63,705 Reputation points Independent Advisor
    2023-05-13T03:04:14+00:00

    Hi RohanS3230, I am Paulo and I'd like to help.

    A method I know to enable it is by creating a batch file. You can copy and paste this in Notepad and then save it as .bat (Ex: hotspot.bat)

    powershell -ExecutionPolicy Bypass "$connectionProfile = [Windows.Networking.Connectivity.NetworkInformation,Windows.Networking.Connectivity,ContentType=WindowsRuntime]::GetInternetConnectionProfile(); $tetheringManager = [Windows.Networking.NetworkOperators.NetworkOperatorTetheringManager,Windows.Networking.NetworkOperators,ContentType=WindowsRuntime]::CreateFromConnectionProfile($connectionProfile); $tetheringManager.StartTetheringAsync();"

    Once you save it, press the Windows key +R then enter shell:startup to open the startup folder and place the file in it.

    7 people found this answer helpful.
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Anonymous
    2023-05-20T20:27:52+00:00

    The script you have provided is glitchy. It works but on some occasions, but I've noticed that sometimes when the script runs, it doesn't assign a gateway (as I've seen on other Windows devices through the ipconfig command), causing me to have to turn off the hotspot and turn it on again (which completely defeats the purpose of having it turn on automatically). I notice that it works directly after a restart, yet not when I shut my PC down at night and turn it on the next day. Can you try to fix the script so it works consistently?

    1 person found this answer helpful.
    0 comments No comments