上次写了一个查看wifi的bat文件(https://www.cnblogs.com/feiquan/p/9823402.html),发现有个问题就没法保存到记事本,而且还要处理不同的系统语言,这次重新更新了一下文件。
获取方式:
1.可直接拷贝代码到记事本后改后缀为bat
2.百度网盘:
链接:https://pan.baidu.com/s/11syCrBvehtpPo7R9cfpk0g
提取码:8qhn
主要有3个文件:
Password是最后密码的存放文件夹,其中的文件是以时间命名的,保证不会覆盖
WiFiPassswordSave.bat 是功能选择界面(直接双击它运行)
seeWiFi.bat :是第一个功能(直接查看wifi密码)
saveWiFi.bat:是第二个功能(保存密码到当前目录下的Password\wifiPassword.txt),如果是直接双击此文件或者不带参数,在输出完成后会自动打开密码所在的文件夹,如果在命令行中输入( saveWiFi.bat h)加入参数 h,将会定位到密码所在的文件夹,并列出文件目录
提示:这三个bat文件必须要放在同一个文件夹下,如果使用cmd命令可单独调用seeWiFi.bat 和saveWiFi.bat
更新情况:
REM echo UpdataDate:2018/10/22 23:41REM echo Version:1.1.1vREM 修复wifi名为空时,打印不完全rem 重命名保存的文件名 主机名+用户名+wifiPassword+当前时间rem 更改临时文件的位置
上代码(可直接拷贝代码到记事本后改后缀为bat):
WiFiPassswordSave.bat
@echo offif not "%OS%"=="Windows_NT" EXITREM if not "%0"=="WiFiPassswordSave.bat" exitchcp 65001 >nulif "%1"=="back" (echo ====================================goto fun)Title WiFiPasswordSaveecho WiFiPasswordSavecolor 07echo ====================================echo Author:feiquanecho Create:2018/10/20 17:39echo UpdataDate:2018/10/22 23:41echo Version:1.1.1vecho Function:See and Save your computer connnect all WiFi passwordREM echo Function:See and Save your computer connnect all WiFi passwordREM 修复wifi名为空时,打印不完全rem 重命名保存的文件名rem 更改临时文件的位置REM echo =====================================rem 删除不需要的文件if exist "%temp%\userfiles.txt" ( del %temp%\userfiles.txt )if exist "%temp%\userfiles2.txt" ( del %temp%\userfiles2.txt )if exist "%temp%\password.txt" (del %temp%\password.txt)if exist "%temp%\wifiPassword2.txt" ( del %temp%\wifiPassword2.txt ):funrem 选择功能echo Select function:echo 1.See WiFi passwordecho 2.Save all Wifi Password to wifipassword.txtecho 3.exitecho =====================================set num=2set /p num=请输入你想执行那个功能^(默认:2^)^:if %num%==1 (rem 功能一:直接查看wifi密码call seeWiFi.bat ) else if %num%==2 (rem 功能二:保存密码到当前目录下的Password\wifi%temp%\password.txtcall saveWiFi.bat ) else (rem 删除不需要的文件if exist "%temp%\userfiles.txt" ( del %temp%\userfiles.txt )if exist "%temp%\userfiles2.txt" ( del %temp%\userfiles2.txt )if exist "%temp%\password.txt" (del %temp%\password.txt)if exist "%temp%\wifiPassword2.txt" ( del %temp%\wifiPassword2.txt )exit)pauseexit
seeWiFi.bat
@echo offif not "%OS%"=="Windows_NT" EXITif not "%0"=="seeWiFi.bat" exitchcp 65001 >nultitle seeWiFiREM echo WiFiPasswordSaveREM echo ====================================REM echo Author:feiquanREM echo Create:2018/10/20 17:39REM echo UpdataDate:2018/10/22 23:41REM echo Version:1.1.1vREM echo Function:See and Save your computer connnect all WiFi passwordREM 修复wifi名为空时,打印不完全rem 重命名保存的文件名rem 更改临时文件的位置REM echo =====================================rem 获取用户配置文件,实时刷新netsh wlan show profiles |find "All User Profile" >%temp%\userfiles.txtrem 提取SSID name powershell -Command "(gc %temp%\userfiles.txt) -replace ' All User Profile : ', ''" >%temp%\userfiles2.txtrem 删除不需要的文件if exist "%temp%\userfiles.txt" ( del %temp%\userfiles.txt )rem 功能一:直接查看wifi密码rem 列出wifi名echo Your computer connnect all WiFi name:for /f "tokens=*" %%f in (%temp%\userfiles2.txt) do echo %%frem 选择wifi,给name赋值echo =====================================:loopset /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 existecho =====================================:continueset con=yset /p con=Continue to look up other WiFi password^(默认:y^/n^/q^)^:if "%con%"=="y" (goto loop) else if "%con%"=="n" (call WiFiPassswordSave.bat back) else if "%con%"=="q" (if exist "%temp%\userfiles.txt" ( del %temp%\userfiles.txt )if exist "%temp%\userfiles2.txt" ( del %temp%\userfiles2.txt )exit) else (goto continue)rem 功能一:end
saveWiFi.bat
@echo offif not "%OS%"=="Windows_NT" EXITif not "%0"=="saveWiFi.bat" exit@echo offchcp 65001 >nultitle saveWiFiREM echo WiFiPasswordSaveREM echo ====================================REM echo Author:feiquanREM echo Create:2018/10/20 17:39REM echo UpdataDate:2018/10/22 23:41REM echo Version:1.1.1vREM echo Function:See and Save your computer connnect all WiFi passwordREM 修复wifi名为空时,打印不完全rem 重命名保存的文件名rem 更改临时文件的位置REM echo =====================================echo Starting working ....rem 删除不需要的文件if "%1"=="h" (if exist "%temp%\userfiles.txt" ( del %temp%\userfiles.txt )if exist "%temp%\userfiles2.txt" ( del %temp%\userfiles2.txt )if exist "%temp%\password.txt" (del %temp%\password.txt)if exist "%temp%\wifiPassword2.txt" ( del %temp%\wifiPassword2.txt ))rem 获取用户配置文件,实时刷新netsh wlan show profiles |find "All User Profile" >%temp%\userfiles.txtrem 提取SSID name powershell -Command "(gc %temp%\userfiles.txt) -replace ' All User Profile : ', ''" >%temp%\userfiles2.txtrem 删除不需要的文件if exist "%temp%\userfiles.txt" ( del %temp%\userfiles.txt )rem 功能二:保存密码到%temp%\password.txtrem 遍历SSID namefor /F "tokens=*" %%i in (%temp%\userfiles2.txt) do (echo ==========================================================>>%temp%\password.txt((netsh wlan show profiles name="%%i" key=clear |find "SSID name")||echo SSID name : "%%i" )>>%temp%\password.txt((netsh wlan show profiles name="%%i" key=clear |find "Key Content")||echo Key Content : NO exist )>>%temp%\password.txt)rem 替换关键字powershell -Command "(gc %temp%\password.txt) -replace 'SSID name', 'Wifi name'" >%temp%\wifiPassword2.txtset cName=%computername%set uName=%username%powershell -Command "(gc %temp%\wifiPassword2.txt) -replace 'Key Content','Password '>%cName%_%uName%_wifiPassword"$(Get-Date -Format 'yyyyMd Hms')".txt"rem 删除不需要的文件if exist "%temp%\userfiles.txt" ( del %temp%\userfiles.txt )if exist "%temp%\userfiles2.txt" ( del %temp%\userfiles2.txt )if exist "%temp%\password.txt" (del %temp%\password.txt)if exist "%temp%\wifiPassword2.txt" ( del %temp%\wifiPassword2.txt )rem 移动文件if not exist Password mkdir Password move %cName%_%uName%_wifiPassword* .\Passwordcd Passwordif not "%1"=="h" (start .\ exit)dirrem 功能二:end