i'm creating batch turn laptop wifi make life easier type lines in cmd each time.
the trouble wifi name set key= insted of 1 enter.
here did:
@echo off set /p option="enter 1 create wifi, enter 2 stop wifi " if %option% equ 1 ( set /p id="enter wifi name:" set /p key="set password:" netsh wlan set hostednetwork mode=allow ssid = %id% key = %key% netsh wlan start hostednetwork ) if %option% equ 2 ( netsh wlan set hostednetwork mode=disallow ) timeout /t 5
while shouldn't have spaces between switch , equal sign, or equal sign , parameter, real culprit because you're using set /p
inside if
statement.
to correct this, you'll need 2 things:
add
setlocal enabledelayedexpansion
top of batch file, after@echo off
statement (so variables inif
block can expanded @ execution time).since we're using
enabledelayedexpansion
, call variables using!!
instead of%%
, such as:
netsh wlan set hostednetwork mode=allow ssid=!id! key=!key!
Comments
Post a Comment