Is it possible to change the WiFi hosted network settings using CMD/BAT/VBS?

你。 提交于 2019-12-21 19:43:01

问题


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
::*************************************************************************************


来源:https://stackoverflow.com/questions/36715753/is-it-possible-to-change-the-wifi-hosted-network-settings-using-cmd-bat-vbs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!