如何知道Windows批处理文件中连接了哪个SSID? [英] How to know which SSID I am connected in Windows batch file?
本文介绍了如何知道Windows批处理文件中连接了哪个SSID?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
目前,我有2个批处理文件,可以使用注册表编辑器打开和关闭代理
For now, I have 2 batch file which turns on and off proxy using Registry Editor
喜欢
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" ^
/v ProxyEnable /t REG_DWORD /d 0 /f
但是,我读到一些可以根据您所连接的网络打开或关闭代理的地方吗?因此,如果我可以获取SSID名称,则可以在其他条件下将其保留在其中
But, I read some where that it is possible to turn on or off proxy based on the network you are connected? So, if I can get the SSID name I can keep this in if else condtion
推荐答案
要简单地获取 SSID
,请执行以下操作:
To simply get the SSID
do:
netsh wlan show interface | findstr /i "SSID"
要将第一个变量设置为变量,请使用for循环(假设您不想使用mac地址):
to set the first one as a variable use a for loop (assuming you do not want to use the mac address):
@echo off
for /f "tokens=3" %%i in ('netsh wlan show interface ^| findstr /i "SSID"') do set "myssid=%%i" & goto next
:next
set "myssid=%myssid: =%"
if /i "%myssid%"=="Spektrum" (
reg add ....
)
if /i "%myssid%"=="someotherSSID" (
reg add ....
)
要按原样完成代码:
@echo off
for /f "tokens=3" %%i in ('netsh wlan show interface ^| findstr /i "SSID"') do set "myssid=%%i" & goto next
:next
echo %myssid%
set "myssid=%myssid: =%"
echo %myssid%
if /i "%myssid%"=="Spectrum" (
echo "Spectrum"
) ELSE (
echo "Other"
)
这篇关于如何知道Windows批处理文件中连接了哪个SSID?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文