netsh wlan show profiles > profile.txt
for /f "skip=9" token=2 delims=:" %i in (profile.txt) do set "var=%i"
netsh wlan show profile name=%var% key=clear
现在如果只有一个SSID,则此命令有效,它显示该SSID的所有详细信息。但是如果有多个SSID,则显示最后一个SSID的详细信息。
如何更改代码以立即获取所有SSID详细信息。
答案 0 :(得分:0)
因为您没有使用代码块,所以您要覆盖变量,最后留下最后一个值并进行处理。而是使用一个块来执行:
netsh wlan show profiles > profile.txt
for /f "skip=9" token=2 delims=:" %i in (profile.txt) do (
set "var=%i"
netsh wlan show profile name=%var% key=clear)
答案 1 :(得分:0)
首先,您应该在管理员权限下执行此批处理,以清除模式显示所有密码。
要解决您的问题,您应该将数据填充到数组中,如下面的代码所示:
@echo off & setlocal enabledelayedexpansion & color 0A
Title %~n0 to get SSID With details
::::::::::::::::::::::::::::::::::::::::::::
:: Automatically check & get admin rights ::
::::::::::::::::::::::::::::::::::::::::::::
Set TmpLogFile=%tmp%\TmpLog.txt
If Exist %TmpLogFile% Del %TmpLogFile%
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
::::::::::::::::::::::::::::
Set "TmpLog=%~dp0%~n0_Tmp.txt"
Set "Log=%~dp0%~n0.txt"
If Exist "%TmpLog%" Del "%TmpLog%"
If Exist "%Log%" Del "%Log%"
rem Populate the array
Set i=0
for /f "skip=1 tokens=2 delims=:" %%a in ('netsh wlan show profiles ^|find /i "Profil"') do (
set /A i+=1
set "list[!i!]=%%a"
)
set SSID=%i%
rem Display array elements for SSID List
cls
for /L %%i in (1,1,%SSID%) do (
echo(
echo SSID number %%i: "!list[%%i]:~1!!"
echo(
)
pause
rem Display array elements for SSID List with details
cls
for /L %%i in (1,1,%SSID%) do (
echo(
echo SSID number %%i: "!list[%%i]:~1!!"
echo(
netsh wlan show profiles "!list[%%i]:~1!!" key=clear
netsh wlan show profiles "!list[%%i]:~1!!" key=clear >> "%TmpLog%"
)
Cmd /U /C Type "%TmpLog%" > "%Log%"
If Exist "%TmpLog%" Del "%TmpLog%"
Start "" "%Log%"
pause
exit /b
另一个批处理文件,用于显示所有SSID及其密码:
@echo off & setlocal enabledelayedexpansion
Title WiFi Password Recovery
Mode con cols=70 lines=20
cls & color 0A & echo.
ECHO **************************************
echo WiFi Password Recovery
ECHO **************************************
echo.
if _%1_==_payload_ goto :payload
:getadmin
echo %~nx0: elevating self
set vbs=%temp%\getadmin.vbs
echo Set UAC = CreateObject^("Shell.Application"^) >> "%vbs%"
echo UAC.ShellExecute "%~s0", "payload %~sdp0 %*", "", "runas", 1 >> "%vbs%"
"%temp%\getadmin.vbs"
del "%temp%\getadmin.vbs"
goto :eof
:payload
echo "SSID" ====^> "Password"
echo "SSID" ====^> "Password" > "%~dp0PassWifi.txt"
for /f "delims=: tokens=1,2" %%a in ('netsh wlan show profiles') do (
if not "%%b"=="" (
set ssid=%%b
set ssid=!ssid:~1!
call :getpass "!ssid!"
)
)
del %temp%\tmp.txt
echo.
echo.
echo Done
If Exist "%~dp0PassWifi.txt" start "" "%~dp0PassWifi.txt"
pause>nul
exit /b
:getpass %1
set name=%1
set name=!name:"=!
netsh wlan show profiles %1 key=clear |find ":" > %temp%\tmp.txt
for /f "delims=: tokens=1,2" %%a in (%temp%\tmp.txt) do set passwd=%%b
set passwd=!passwd:~1!
echo "!name!" ====^> "!passwd!"
echo "!name!" ====^> "!passwd!" >> "%~dp0PassWifi.txt"
exit /b