enable Win10 inbuild hotspot by cmd/batch/powershell

前端 未结 7 1953
渐次进展
渐次进展 2020-12-31 10:59

as the title says I search for a way to enable/disable the Hotspot inbuild in Win10 via the command prompt/powershell/a batch file. In the GUI it can be easily done with the

7条回答
  •  悲&欢浪女
    2020-12-31 11:22

    By Using CMD. It is too Simple to turn PC as Hotspot. But you PC must have Hosted network supported, to check it out try this command

        @echo off
    REM    Copyright (C) 2013  
    REM    user49828
    REM
    REM    Batch file for creating Wifi Hotspot
    if _%1_==_payload_  goto :payload
    
    :getadmin
        echo %~nx0: elevating self
        set vbs=%temp%\getadmin.vbs
        echo Set UAC = CreateObject^("Shell.Application"^)                >> "%vbs%"
        echo UAC.ShellExecute "%~s0", "payload %~sdp0 %*", "", "runas", 1 >> "%vbs%"
        "%temp%\getadmin.vbs"
        del "%temp%\getadmin.vbs"
    goto :eof
    
    :payload
        echo %~nx0: running payload with parameters:
        echo %*
        echo ---------------------------------------------------
        cd /d %2
        shift
        shift
        rem put your code here
        rem e.g.: perl myscript.pl %1 %2 %3 %4 %5 %6 %7 %8 %9
        :start
    @ECHO off
    ECHO  Pleae select one of the options Programmed By Overflown.com  "user49828"
    ECHO  --------------------------------------------------------------------------------------------------------------------------
    ECHO  1 Hotspot settings
    ECHO  2 Start Hotspot
    ECHO  3 Stop  Hotspot
    ECHO  --------------------------------------------------------------------------------------------------------------------------
    
    SET /p option=Please enter one of the options:
    
    if %option%==1  ( goto setup )      else set /a er=1
    if %option%==2  ( goto start1 )      else set /a er=er+1
    if %option%==3  ( goto stop )       else set /a er=er+1
    
    :noOption
    if %er% GEQ 3 ( 
    Echo Error!
    Echo Please enter a correct option
    @pause
    cls  
    goto start
    )
    
    :setup
    SET /p ssid=Please enter the Hotspot name:
    SET /p key=Please enter the Hotspot password greater the 8 digits:
    netsh wlan set hostednetwork mode=allow ssid=%ssid% key=%key% 
    if %errorlevel%==0 (
    ECHO Setup complete
    )
    @pause
    cls  
    goto start
    
    :start1
    netsh wlan start hostednetwork
    @pause
    cls  
    goto start
    
    :stop
    netsh wlan stop hostednetwork
    @pause
    cls  
    goto start
    goto :eof
    

提交回复
热议问题