Skip to content

Instantly share code, notes, and snippets.

@shalzz
Last active March 11, 2021 21:06
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shalzz/7586870 to your computer and use it in GitHub Desktop.
Save shalzz/7586870 to your computer and use it in GitHub Desktop.
[Windows Wifi Hotspot] Batch file for creating Wifi Hotspot using Microsoft Hosted Network Virtual Adapter #windows
@echo off
REM Copyright (C) 2013
REM Shaleen Jain
REM shalzz@outlook.com
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
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
@YLaido
Copy link

YLaido commented Jun 10, 2016

Pretty convenient.Thanks. :)

@xiarahman
Copy link

Spell mistake at line 29.

@DMeurer
Copy link

DMeurer commented Apr 30, 2019

Thank you so much

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment