[英]Is there a variable for the connected wlan?
I started writing this small batch file, where I get all the wlan data with: 我开始写这个小批处理文件,在其中获取所有wlan数据:
netsh wlan show profile (name) key=clear
This is not a problem but I am asking if there is a variable like for example: 这不是问题,但是我问是否有一个变量,例如:
%CurrentWlan%
so I can do: 所以我可以做:
netsh wlan show profile %CurrentWlan% key=clear >wlan.txt
Here is a possible solution: 这是一个可能的解决方案:
@echo off
for /f "eol=B tokens=*" %%A IN ('netsh wlan show interfaces ^| findstr SSID') do (
for /f "delims=: tokens=2" %%A IN ("%%A") do (
for /f "tokens=*" %%A IN ("%%A") do (
netsh wlan show profiles "%%A" key=clear >wlan.txt
)
)
)
Which I am going to break it down: 我要分解的是:
netsh wlan show interfaces
searching for SSID
string. netsh wlan show interfaces
的输出,以搜索SSID
字符串。 As there is also a line containing B
SSID
we ignore it with eol=B
. B
SSID
的行,因此我们用eol=B
忽略它。
:
symbol, so we set it as delimeter. :
符号后解析值,因此我们将其设置为delimeter。 We can access the network name, now, setting tokens
to 2
. tokens
设置为2
。
for
loop specifying tokens
option to *
. for
循环,将结果中所有不需要的空格删除,将*
tokens
指定为tokens
选项。
%%A
). %%A
)的所有信息。 We redirect output to wlan.txt
. wlan.txt
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.