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

对着背影说爱祢 提交于 2019-12-04 09:50:44

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