批处理脚本:
for /f "tokens=2*delims=: " %%i in ('netsh wlan show networks^|find /i "SSID"') do ( echo %%i.%%j )
for /f "tokens=2*delims=: " %%i in ('netsh wlan show networks^|find /i "authentication"') DO (echo %%i )
我需要这样的输出:
1. SSIDname1 : WPA2-personal
2. SSIDname2 : Open
3. ....
我尝试过这种方法,但失败了:
for /f "tokens=2*delims=: " %%a in ('netsh wlan show networks^|find /i "authentication"') do (
for /f "tokens=2*delims=: " %%i in ('netsh wlan show networks^|find /i "SSID"') do (
echo %%i.%%j = %%a))
这里有一个完整的批处理文件解决方案,以满足发布时的要求。
@Echo Off
SetLocal DisableDelayedExpansion
Set "#=0"
For /F "Tokens=1* Delims=:" %%G In (
'^""%__AppDir__%netsh.exe" WLAN Show Networks 2^> NUL ^|^
"%__AppDir__%findstr.exe" "^SSID> <Authentication>"^"'
) Do Set "i=%%G" & For /F "Tokens=*" %%I In ("%%H") Do (Set /A # %%= 2
SetLocal EnableDelayedExpansion
Set "i=!i:~,-1!. " & If !#! Equ 0 (If "%%I"=="" (
Set /P "_=!i:* =!*Cloaked*: "<NUL) Else Set /P "_=!i:* =!%%I: "<NUL
) Else Echo !_!%%I
EndLocal & Set /A # += 1)
Pause
由于您自己没有尝试执行任务,因此如果您决定在提交问题或要求后修改问题或要求,将不会对所提供的代码进行解释,也不会对其进行修改