Windows’ Batch for Quickly set a HostSpot

Update: A better option could be use a windows’ software which one automate all, my suggestion is to use “Mars Wifi” <http://en.zkytech.com/v2/index.html>

The next content is for set a Hostspot in Windows through an interactive Batch file (.bat) using some command lines (with admin privilegies). Very useful in the offices if you need to share the intranet with other devices and there’s no enough ethernet connetions.

Just is needed to copy the next script into a notepad and save it with “.bat” extension.

@echo off
REM --> Check for permissions
IF "%PROCESSOR_ARCHITECTURE%" EQU "amd64" (
>nul 2>&1 "%SYSTEMROOT%\SysWOW64\cacls.exe" "%SYSTEMROOT%\SysWOW64\config\system"
) ELSE (
>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"
)
REM --> If error flag set, we do not have admin.
if '%errorlevel%' NEQ '0' (
echo Requesting administrative privileges...
goto UACPrompt
) else ( goto gotAdmin )
:UACPrompt
echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
set params = %*:"=""
echo UAC.ShellExecute "cmd.exe", "/c ""%~s0"" %params%", "", "runas", 1 >> "%temp%\getadmin.vbs"
"%temp%\getadmin.vbs"
del "%temp%\getadmin.vbs"
exit /B
:gotAdmin
pushd "%CD%"
CD /D "%~dp0"
:menu
echo #####################################################################
echo # SELECCIONE ACCION A EFECTUAR: #
echo # 1. Activar Hostspot "J.A.R.V.I.S." con Password "1357924680" #
echo # 2. Reiniciar el Hostspot #
echo # 3. Apagar Hostspot #
echo # 4. Salir #
echo #####################################################################
SET /P ver= "> Indique Accion: "
if %ver%==1 goto crear
if %ver%==2 goto reiniciar
if %ver%==3 goto apagar
if %ver%==4 goto salir
echo ----------------------------------------------------------------------
echo.
echo.
:crear
netsh wlan set hostednetwork mode=allow ssid=J.A.R.V.I.S. key=1357924680
netsh wlan start hostednetwork
ncpa.cpl
echo > Se ha creado el Hostspot! :D
SET /P ver=Presionar ENTER para voler volver al menu...
echo ----------------------------------------------------------------------
echo.
echo.
goto menu
:reiniciar
netsh wlan stop hostednetwork
netsh wlan set hostednetwork mode=allow ssid=J.A.R.V.I.S. key=1357924680
netsh wlan start hostednetwork
ncpa.cpl
echo > Se ha reiniciado el Hostspot! :D
SET /P ver=Presionar ENTER para voler volver al menu...
echo ----------------------------------------------------------------------
echo.
echo.
goto menu
:apagar
netsh wlan stop hostednetwork
echo > Se ha apagado el Hostspot! :D
SET /P ver=Presionar ENTER para voler volver al menu...
echo ----------------------------------------------------------------------
echo.
echo.
goto menu
:salir
exit

This is how looks the script running (after allow admin privilegies):

The script will open the Windows’ Network Connections automatically, this is require because you will need to set manually share the internet traffic to the new wifi adapter (in this case from “Ethernet” adapter to “Conexión de area local* 1”)… and that’s all, the WiFi will sharing the access to the intranet wirelessly.