如何合并 netsh wlan show networks 的输出 | findstr /L /I "SSID authentication"?
How to combine output of netsh wlan show networks | findstr /L /I "SSID authentication"?
批处理脚本:
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
由于您自己没有尝试执行此任务,因此如果您决定修改问题,则不会对所提供的代码进行任何解释,也不会对其进行任何修改,或者提交后的要求。
批处理脚本:
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
由于您自己没有尝试执行此任务,因此如果您决定修改问题,则不会对所提供的代码进行任何解释,也不会对其进行任何修改,或者提交后的要求。