Is it possible to change the WiFi hosted network s

2019-04-10 03:25发布

问题:

I was trying to change two hosted network settings of my WiFi hotspot using CMD/BAT/VBS, but I was unable to do it.

The Settings I want to change:

  1. Authentication (eg: WPA,WPA2PSK)
  2. Cipher (eg: CCMP/AES)

The following code gives the information about the hosted network settings:

netsh wlan show hostednetwork

The following code sets the profile parameters:

netsh wlan set profileparameter

The problem is: what is the profile name which runs the WiFi Hotspot. The profileparameter asks for the profile name, and I dont know it. I have tried exporting the profile but it does not contain the profile name. Exported profile data is located in windows/system32 directory.

Is there a way to solve this issue?

Resource: Netsh Commands for WLAN

回答1:

Try this code to get the profil name and its password with admin rights :

@echo off
Title Get the Wifi Profile Name with its password by Hackoo tested on french machine
cls & color 0A & echo.
Mode con cols=80 lines=5
:::::::::::::::::::::::::::::::::::::::::
:: Automatically check & get admin rights
:::::::::::::::::::::::::::::::::::::::::
Set TmpLogFile=TmpLogkey.txt
Set LogFile=Wifikey_Log.txt
If Exist %TmpLogFile% Del %TmpLogFile%
If Exist %LogFile% Del %LogFile%
REM  --> Check for permissions
Reg query "HKU\S-1-5-19\Environment" >%TmpLogFile% 2>&1
REM --> If error flag set, we do not have admin.
if '%errorlevel%' NEQ '0' (
Echo.
ECHO                 **************************************
ECHO                  Running Admin shell... Please wait...
ECHO                 **************************************

    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

::::::::::::::::::::::::::::
::START
::::::::::::::::::::::::::::
setlocal enabledelayedexpansion
for /f "tokens=2 delims=:" %%a in ('netsh wlan show int ^|find /i "profil"') do ( set ProfilName=%%a
    Call:Trim "!ProfilName!"
    echo The profile name is : "!ProfilName!"
    echo The profile name is : "!ProfilName!" > %LogFile%
)
pause
Cls 
echo(
echo The password of your Wifi Network is :
Netsh wlan show profiles name="!ProfilName!" key=clear |Find /i "Conten"
(
    echo The password of your Wifi Network is :
    Netsh wlan show profiles name="!ProfilName!" key=clear |Find /i "Conten"
)>>%LogFile%
pause
Start "" %LogFile%
 ::*************************************************************************************
:Trim <String>
(
    echo Wscript.echo Trim("%~1"^)
)>"%~n0.vbs"
for /f "delims=" %%a in ('Cscript /nologo "%~n0.vbs"') do ( set "Profilname=%%a" )
exit /b
::*************************************************************************************