我创建这个批处理脚本是为了提取以前连接到我设备的任何Wi的密码。这个脚本要求用户输入SSID,然后使用netsh wlan show profile=%Wi-Fi name% key=clear提取密码,但是在执行时,我多次遇到这个错误:' ' is not recognized as an internal or external command, operable program or batch file.。
我尝试用实际的代码(即cmnd语句中的netsh wlan.... )替换变量FOR \f,但是没有明显的输出。
对于做错了什么有什么建议吗?
我的守则:
@echo Welcome to this Password Extractor tool.
set /p WiFi_Name=Enter the SSID.
set cmnd=netsh wlan show profile name=%WiFi_Name% key=clear
for /f "tokens=1-2,17" %%i in ('%cmnd%') do ^
if "%%i %%j"=="Key Content" set PASS=%%k
echo%PASS%
Pause“命令提示符”窗口显示以下错误:
Welcome to this Password Extractor tool.
C:\Program Files\PowerToys>set /p WiFi_Name=Enter the SSID.
Enter the SSID.Skti
C:\Program Files\PowerToys>set cmnd=netsh wlan show profile name=Skti key=clear
C:\Program Files\PowerToys>for /F "tokens=1-2,17" %i in ('netsh wlan show profile name Skti key clear') do
C:\Program Files\PowerToys>
' ' is not recognized as an internal or external command,
operable program or batch file.
C:\Program Files\PowerToys>
' ' is not recognized as an internal or external command,
operable program or batch file.
C:\Program Files\PowerToys>
' ' is not recognized as an internal or external command,
operable program or batch file.
C:\Program Files\PowerToys>
' ' is not recognized as an internal or external command,
operable program or batch file.
C:\Program Files\PowerToys>
' ' is not recognized as an internal or external command,
operable program or batch file.
C:\Program Files\PowerToys>
' ' is not recognized as an internal or external command,
operable program or batch file.
C:\Program Files\PowerToys>
' ' is not recognized as an internal or external command,
operable program or batch file.
C:\Program Files\PowerToys>
' ' is not recognized as an internal or external command,
operable program or batch file.
C:\Program Files\PowerToys>
' ' is not recognized as an internal or external command,
operable program or batch file.
C:\Program Files\PowerToys>
' ' is not recognized as an internal or external command,
operable program or batch file.
C:\Program Files\PowerToys>
' ' is not recognized as an internal or external command,
operable program or batch file.
C:\Program Files\PowerToys>
' ' is not recognized as an internal or external command,
operable program or batch file.
C:\Program Files\PowerToys>
' ' is not recognized as an internal or external command,
operable program or batch file.
C:\Program Files\PowerToys>
' ' is not recognized as an internal or external command,
operable program or batch file.
C:\Program Files\PowerToys>
' ' is not recognized as an internal or external command,
operable program or batch file.
C:\Program Files\PowerToys>
' ' is not recognized as an internal or external command,
operable program or batch file.
C:\Program Files\PowerToys>
' ' is not recognized as an internal or external command,
operable program or batch file.
C:\Program Files\PowerToys>
' ' is not recognized as an internal or external command,
operable program or batch file.
C:\Program Files\PowerToys>
' ' is not recognized as an internal or external command,
operable program or batch file.
C:\Program Files\PowerToys>
' ' is not recognized as an internal or external command,
operable program or batch file.
C:\Program Files\PowerToys>
' ' is not recognized as an internal or external command,
operable program or batch file.
C:\Program Files\PowerToys>
' ' is not recognized as an internal or external command,
operable program or batch file.
C:\Program Files\PowerToys>
' ' is not recognized as an internal or external command,
operable program or batch file.
C:\Program Files\PowerToys>
' ' is not recognized as an internal or external command,
operable program or batch file.
C:\Program Files\PowerToys>if "%i %j" == "Key Content" set PASS=%k
C:\Program Files\PowerToys>echo
ECHO is on.发布于 2021-06-15 10:17:24
我建议你用一些更结实的东西:
For /F "Tokens=3,*" %%G In ('%SystemRoot%\System32\netsh.exe WLAN Show Profiles Name^="%WiFi_Name%" Key^="Clear" 2^>NUL ^| %SystemRoot%\System32\findstr.exe /RC:"^ *Key Content *: *[^ ][^ ]*.*$"') Do Set "PASS=%%H"…如果您想要分割长行以提高可读性,那么:
For /F "Tokens=3,*" %%G In ('%SystemRoot%\System32\netsh.exe WLAN Show Profiles
Name^="%WiFi_Name%" Key^="Clear" 2^>NUL ^| %SystemRoot%\System32\findstr.exe
/RC:"^ *Key Content *: *[^ ][^ ]*.*$"') Do Set "PASS=%%H"请注意,netsh.exe输出是以配置的系统语言返回的,因此如果您打算分发此输出,请注意任何密码都不会总是前面有区分英文大小写的字符串Key Content。
发布于 2021-06-21 14:28:00
它可以解决你的问题。
@ECHO OFF
echo Welcome to this Password Extractor tool.
set /p WiFi_Name=Enter the SSID:
netsh wlan show profile name=%WiFi_Name% key=clear>"%tmp%\wifi.log"
findstr /n "Key Content" "%tmp%\wifi.log">"%tmp%\wifi1.log"
del /q /f "%tmp%\wifi.log"
set /p pass=<%tmp%\wifi1.log
for /f "tokens=3 delims=:" %%a in ("%pass%") do (
SET PASS=%%a
)
SET PASS=%PASS%B
del /q /f "%tmp%\wifi1.log"
set PASS=%PASS:~1,-1%
ECHO PASSWORD: %PASS%
pause它在临时文件夹中创建一些必需的文件,并在操作完成后移除。
https://stackoverflow.com/questions/67982826
复制相似问题