使用cmd查看电脑连接过的wifi密码

Posted feiquan

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了使用cmd查看电脑连接过的wifi密码相关的知识,希望对你有一定的参考价值。

上次写了一个查看wifi的bat文件(https://www.cnblogs.com/feiquan/p/9823402.html),发现有个问题就没法保存到记事本,而且还要处理不同的系统语言,这次重新更新了一下文件。

获取方式

  1.可直接拷贝代码到记事本后改后缀为bat

  2.百度网盘:

    链接:https://pan.baidu.com/s/1VRSRHA9GLFTt6FcVrpHucw
    提取码:w3bw

主要有3个文件:

技术分享图片

Password是最后密码的存放文件夹,其中的文件是以时间命名的,保证不会覆盖

WiFiPassswordSave.bat 是功能选择界面(直接双击它运行)

seeWiFi.bat :是第一个功能(直接查看wifi密码)

saveWiFi.bat:是第二个功能(保存密码到当前目录下的PasswordwifiPassword.txt),如果是直接双击此文件或者不带参数,在输出完成后会自动打开密码所在的文件夹,如果在命令行中输入( saveWiFi.bat  h)加入参数 h,将会定位到密码所在的文件夹,并列出文件目录

提示:这三个bat文件必须要放在同一个文件夹下,如果使用cmd命令可单独调用seeWiFi.bat 和saveWiFi.bat

上代码(可直接拷贝代码到记事本后改后缀为bat):

WiFiPassswordSave.bat 

@echo off
if not "%OS%"=="Windows_NT" EXIT
REM if not "%0"=="WiFiPassswordSave.bat" exit
chcp 65001
if "%1"=="back" (
echo ====================================
goto fun
)
echo WiFiPasswordSave
echo ====================================
echo Author:feiquan
echo Create:2018/10/20 17:39
echo UpdataDate:2018/10/21 20:12
echo Version:1.1v
echo Function:See and Save your computer connnect all WiFi password
echo =====================================


:fun
rem 选择功能
echo Select function:
echo     1.See WiFi password
echo     2.Save all Wifi Password to wifiPassword.txt
echo     3.exit
echo =====================================

set num=2
set /p num=请输入你想执行那个功能^(默认:2^)^:

if %num%==1 (
rem 功能一:直接查看wifi密码
call seeWiFi.bat 

) else if %num%==2 (
rem 功能二:保存密码到当前目录下的PasswordwifiPassword.txt
call saveWiFi.bat 

) else (
rem 删除不需要的文件
if exist "userfiles.txt"  ( del userfiles.txt )
if exist "userfiles2.txt"  ( del userfiles2.txt )
if exist "password.txt"  (del password.txt)
if exist "wifiPassword2.txt"  ( del wifiPassword2.txt )

exit
)

pause
exit

 

seeWiFi.bat 

@echo off
if not "%OS%"=="Windows_NT" EXIT
if not "%0"=="seeWiFi.bat" exit
chcp 65001
REM echo WiFiPasswordSave
REM echo ====================================
REM echo Author:feiquan
REM echo Create:2018/10/20 17:39
REM echo UpdataDate:2018/10/21 20:12
REM echo Version:1.1v
REM echo Function:See your computer connnect all WiFi password
REM echo =====================================


rem 获取用户配置文件,实时刷新
netsh wlan show profiles |find "All User Profile" >userfiles.txt
rem 提取SSID name 
powershell -Command "(gc .userfiles.txt) -replace ‘    All User Profile     : ‘, ‘‘" >userfiles2.txt

rem 删除不需要的文件
if exist "userfiles.txt"  ( del userfiles.txt )

rem 功能一:直接查看wifi密码
rem 列出wifi名
echo Your computer connnect all WiFi name:
for /F %%f in (userfiles2.txt) do echo        %%f
rem 选择wifi,给name赋值
echo =====================================
:loop
set /p name=Please input your WiFi name(SSID):
( netsh wlan show profiles name="%name%" key=clear |find "SSID name" ) ||echo     SSID name              : "%name%" 
( netsh wlan show profiles name="%name%" key=clear |find "Key Content" ) ||echo     Key Content            : NO exist
echo =====================================
:continue
set temp=y
set /p temp=Continue to look up other WiFi password^(默认:y^/n^/q^)^:
if "%temp%"=="y" (
goto loop
) else if "%temp%"=="n" (
call WiFiPassswordSave.bat back

) else if "%temp%"=="q" (
if exist "userfiles.txt"  ( del userfiles.txt )
if exist "userfiles2.txt"  ( del userfiles2.txt )
exit
) else (
goto continue
)
rem 功能一:end

 

saveWiFi.bat

@echo off
if not "%OS%"=="Windows_NT" EXIT
REM if not "%0"=="saveWiFi.bat" exit
chcp 65001
REM echo WiFiPasswordSave
REM echo ====================================
REM echo Author:feiquan
REM echo Create:2018/10/20 17:39
REM echo UpdataDate:2018/10/21 20:12
REM echo Version:1.1v
REM echo Function:Save your computer connnect all WiFi password
REM echo =====================================


rem 获取用户配置文件,实时刷新
netsh wlan show profiles |find "All User Profile" >userfiles.txt
rem 提取SSID name 
powershell -Command "(gc .userfiles.txt) -replace ‘    All User Profile     : ‘, ‘‘" >userfiles2.txt

rem 删除不需要的文件
if exist "userfiles.txt"  ( del userfiles.txt )

rem 功能二:保存密码到当前目录下的wifiPassword.txt

rem 遍历SSID name
for /F %%i in (.userfiles2.txt) do (
echo ==========================================================>>password.txt
((netsh wlan show profiles name="%%i" key=clear |find "SSID name")||echo     SSID name              : "%%i"  )>>password.txt
((netsh wlan show profiles name="%%i" key=clear |find "Key Content")||echo     Key Content            : NO exist )>>password.txt
)

rem 替换关键字
powershell -Command "(gc .password.txt) -replace ‘SSID name‘,  ‘Wifi name‘" >wifiPassword2.txt
powershell -Command "(gc .wifiPassword2.txt) -replace ‘Key Content‘,‘Password   ‘>wifiPassword"$(Get-Date -Format yyyyMd Hms)".txt"

rem 删除不需要的文件
if exist "userfiles.txt"  ( del userfiles.txt )
if exist "userfiles2.txt"  ( del userfiles2.txt )
if exist "password.txt"  (del password.txt)
if exist "wifiPassword2.txt"  ( del wifiPassword2.txt )

rem 移动文件
if not exist Password mkdir Password 
move wifiPassword* .Password
cd Password

if not "%1"=="h" (
start . 
exit
)

dir
rem 功能二:end

 


以上是关于使用cmd查看电脑连接过的wifi密码的主要内容,如果未能解决你的问题,请参考以下文章

查看曾经连接过的WiFi密码

通过电脑获取WIFI密码(只能连接过的WiFi)

连接过的wifi可以查看密码

查看计算机连接过的WiFi密码(三种方法)

教大家CMD下一键获取所有连接过的WIFI密码

win10以前连接过的wifi密码怎么查看