表白:黑白圣堂血天使,天剑鬼刀阿修罗。 讲解对象:/cmd 输出电脑所有wifi密码 作者:融水公子 rsgz
今天探究一下怎么系统输出所有WiFi密码 下面是探索过程
下面第一段代码能够实现输出系统里面所有的wifi名字
@echo off
chcp 65001
echo -------------------------------------------------------------------------------------
if exist 001001xy.txt (del 001001xy.txt)
for /f "usebackq skip=1 eol=; tokens=4,* delims=: " %%i in (`netsh wlan show profile ^| find ":"`) do (echo %%i %%j >>001001xy.txt)
echo -------------------------------------------------------------------------------------
pause wifi名字输出汇总到001001xy.txt文件 之所以保存到txt文件就是为了去空格 这里明显有两个空格 这种去空格的写法行不通
现在通过这样的写法 将末尾的空格去掉
@echo off
chcp 65001
echo -------------------------------------------------------------------------------------
echo ===1====
:: 获取电脑内wifi名 保存到 001001xy.txt文件
if exist 001001xy.txt (del 001001xy.txt)
for /f "usebackq skip=1 eol=; tokens=4,* delims=: " %%i in (`netsh wlan show profile ^| find ":"`) do (echo %%i %%j>>001001xy.txt)
echo ===2====
:: SETLOCAL ENABLEEXTENSIONS
:: 读取001001xy.txt文件里面的wifi名 去掉末尾空格
SETLOCAL ENABLEDELAYEDEXPANSION
for /f "eol=; tokens=*" %%i in (001001xy.txt) do (
set a=%%i
::if "!a:~-1!"==" " (echo asas)
if "!a:~-1!"==" " (set a=!a:~0,-1!) else (set a=!a!)
echo "!a!" "!a:~-1!"
echo !a!>>001002xy.txt
echo.
)
echo -------------------------------------------------------------------------------------
pause 大家看看结果 末尾并不是空格 后来经过深入研究 已经把所有的难题解决了
@echo off
chcp 65001
echo -------------------------------------------------------------------------------------
echo ===1====
:: 获取电脑内wifi名 保存到 001001xy.txt文件
if exist 001001xy.txt (del 001001xy.txt)
for /f "usebackq skip=1 eol=; tokens=4,* delims=: " %%i in (`netsh wlan show profile ^| find ":"`) do (
rem echo "%%i %%j"
echo %%i %%j>>001001xy.txt
)
echo.
echo ===2====
:: SETLOCAL ENABLEEXTENSIONS
:: 读取001001xy.txt文件里面的wifi名 去掉末尾空格
if exist 001002xy.txt (del 001002xy.txt)
SETLOCAL ENABLEDELAYEDEXPANSION
for /f "eol=; tokens=*" %%i in (001001xy.txt) do (
set a=%%i
::if "!a:~-1!"==" " (echo asas)
if "!a:~-1!"==" " (set a=!a:~0,-1!) else (set a=!a!)
rem echo "!a!" "!a:~-1!"
echo !a!>>001002xy.txt
echo.
)
echo.
echo ===3 本机所有WiFi密码:====
if exist 001003xy.txt (del 001003xy.txt)
if exist 001004xy.txt (del 001004xy.txt)
rem SETLOCAL ENABLEDELAYEDEXPANSION
for /f "eol=; tokens=*" %%i in (001002xy.txt) do (
for /f "eol=; tokens=3,* delims=: " %%j in ('netsh wlan show profile name^="%%i" key^=clear ^| find "Key Content"') do (
echo %%i ==^> %%j
)
echo.
)
echo.
::echo %a:~22,50%
::for /f "delims=-" %%i in ('netsh wlan show profile name^="Tenda_E6F2E0 2" key^=clear ^| find "关键内容"') do (set var=%%i )
if exist 001001xy.txt (del 001001xy.txt)
if exist 001002xy.txt (del 001002xy.txt)
if exist 001003xy.txt (del 001003xy.txt)
if exist 001004xy.txt (del 001004xy.txt)
echo -------------------------------------------------------------------------------------
pause 给大家展示一下效果
牛逼吧???哈哈哈 但是我写的这段脚本 很可能过一两天就忘了!所以呢 我就视频讲解一下这段代码 希望能帮助大家 B站 融水公子 https://www.bilibili.com/video/BV1dq4y1v7qw/ === 公众号:不浪仙人 谢谢大家的支持!可以点击我的头像,进入我的空间浏览更多文章呢。建议大家360doc[www.360doc.com]注册一个账号登录,里面真的有很多优秀的文章,欢迎大家的到来。 ---
|