Skip to content

Instantly share code, notes, and snippets.

@Rillke
Forked from Mithrandir0x/disable_wifi_hotspot.bat
Last active February 9, 2016 13:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Rillke/df69f0dfc3fbce01784d to your computer and use it in GitHub Desktop.
Save Rillke/df69f0dfc3fbce01784d to your computer and use it in GitHub Desktop.
Two little batch files to create a cozy WiFi hotspot from the laptop.
@ECHO OFF
ECHO Setting up or shutting down a hosted network
SET /P ACTION="ENABLE [E] DISABLE [D] INFO[I]: "
IF /I "%ACTION:~,1%" EQU "E" GOTO enable
IF /I "%ACTION:~,1%" EQU "D" GOTO disable
IF /I "%ACTION:~,1%" EQU "I" GOTO info
GOTO unknown
:enable
SET DEFAULT_SSID=rillke's hotspot
SET DEFAULT_PASS=MUST_BE_SET_TO_SOMETHING_REALLY_SECURE
SET SSID=%DEFAULT_SSID%
SET PASS=%DEFAULT_PASS%
SET /P SSID="Enter WiFi SSID [%DEFAULT_SSID%]: "
SET /P PASS="Enter WiFi password [%DEFAULT_PASS%]: "
IF /I "%SSID%" == "" (
SET SSID=%DEFAULT_SSID%
)
IF /I "%PASS%" == "" (
SET PASS=%DEFAULT_PASS%
)
netsh wlan set hostednetwork mode=allow ssid="%SSID%" key="%PASS%"
timeout 1
netsh wlan start hostednetwork
ECHO You can now connect to the hosted network.
ECHO SSID: %SSID%
ECHO PASS: %PASS%
SET SSID=
SET PASS=
ECHO If you also would like to share the internet connection, you need to do so
ECHO from the network with internet connection (Right click -> Properties -> Share)
ECHO with the newly created hosted network (usually WiFi conncetion 2 or similar)
timeout 4
ncpa.cpl
GOTO exit
:disable
netsh wlan stop hostednetwork
timeout 3
netsh wlan set hostednetwork mode=disallow
GOTO exit
:info
netsh wlan show hostednetwork
netsh wlan show hostednetwork setting=security
ECHO Connected clients
arp -a | findstr -i replace_with_the_ip_to_filter_with
GOTO exit
:unknown
ECHO Unknown command.
:exit
ECHO Bye.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment