我正在嘗試使用批處理檔案獲取 wifi 密碼,但未正確讀取一個命令(我的解釋)。
Netsh WLAN show profile name= %WifiName% key='clear'
變成
Netsh WLAN show profile name= %WifiName% key 'clear'
跑進去的時候
for /f "tokens=*" %%i in ('Netsh WLAN show profile name= %WifiName% key="clear"') do ^
echo "%%i"
如果您需要更多資訊,請提供,但我太愚蠢了,現在想不出任何資訊。
整個代碼
for /f "tokens=5" %%i in ('Netsh WLAN show profile') do ^
set WifiName=%%i
Netsh WLAN show profile name= %WifiName% key='clear'
for /f "tokens=*" %%i in ('Netsh WLAN show profile name= %WifiName% key"=""clear"') do ^
echo "%%i"
pause
uj5u.com熱心網友回復:
您需要=
在for
回圈中轉義。這是一個適合您的作業示例。
@echo off
for /f "tokens=2*delims=:" %%a in ('netsh wlan show profile ^|find /i "All User Profile"') do (
for /f "tokens=2*delims=:" %%i in ('netsh wlan show profile name^=%%a key^=clear ^| findstr /C:"Key Content"') do echo Wifi: %%a pass: %%i
)
正如您在我的示例中所看到的,第二個for
是針對前一個中的每個元變數運行的for
。在您的示例中(盡管不起作用),您設定了所有變數,并且只使用了最后一個變數。
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/507896.html
標籤:批处理文件