zilexa

WiFi Hotspot switch.cmd

Apr 14th, 2016
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. @ECHO off
  2.  
  3. :: Please create your hotspot first by running the command.
  4. :: Start "cmd", you will see "command prompt" as a result. right click and select "run as administrator"
  5.  
  6. :: Copy paste: netsh wlan set hostednetwork mode=allow ssid=NAME key=PASSWORD
  7.  
  8. :: change SSID to your desired Hotspot name and change PASSWORD to an 8-character password and hit ENTER.  
  9. do this if your mobile device cannot get an IP and WIFI connection fails:
  10. 1) Disable Internet Connection Sharing from your modem connection -> properties -> Sharing Tab
  11.  
  12. 2) Enable it again.
  13.  
  14. 3) Disconnect from the Internet.
  15.  
  16. 4) Reconnect again
  17.  
  18. 5) Restart ICS service from the "services.msc" window.
  19.  
  20. 6) Stop the hostednetwork
  21.  
  22. 7) Start the hostednetwork
  23.  
  24. 8) Internet Sharing is now enabled and everything gets resolved.
  25.  
  26.  
  27. @ECHO off
  28. :: Create a notification message; Disabled
  29.   echo set WshShell = WScript.CreateObject("WScript.Shell") > %tmp%\tmp0.vbs
  30.   echo WScript.Quit (WshShell.Popup( "Hotspot OFF" ,2 ,"Click OK", 0)) >> %tmp%\tmp0.vbs
  31.  
  32. :: Create a notification message; Enabled
  33.   echo set WshShell = WScript.CreateObject("WScript.Shell") > %tmp%\tmp1.vbs
  34.   echo WScript.Quit (WshShell.Popup( "Hotspot ON" ,2 ,"Click OK", 0)) >> %tmp%\tmp1.vbs
  35.  
  36. :: Check if the Hotspot is already on, if it is turn it off, otherwise turn it on.
  37. netsh wlan show hostednetwork | findstr /i "Channel"
  38.   if  %ERRORLEVEL% EQU 1 (
  39.   C:\Windows\System32\netsh.exe wlan start hostednetwork
  40.   ) else (
  41.   C:\Windows\System32\netsh.exe wlan stop hostednetwork
  42. )
  43.  
  44. :: Now do the same check but display a message showing the status of the Hotspot.
  45. netsh wlan show hostednetwork | findstr /i "Channel"
  46. if  %ERRORLEVEL% EQU 1 (
  47.   cscript /nologo %tmp%\tmp0.vbs
  48.   ) else (
  49.   cscript /nologo %tmp%\tmp1.vbs
  50. )
  51.  
  52. :: Cleanup the notification message files
  53. DEL /F /S /Q /A %tmp%\tmp0.vbs
  54. DEL /F /S /Q /A %tmp%\tmp1.vbs
Add Comment
Please, Sign In to add comment