Windows关于无线网络的命令
全程cmd命令行操作
1 查看已保存连接的密码
1.1 查看连接信息
netsh wlan show profiles
1.2 查看密码
netsh wlan show profile name=WiFi名 key=clear
2 创建热点(开启承载网络模式)
需要以管理员身份运行
2.1 设置本机无线SSID和密码
netsh wlan set hostednetwork mode=allow 自定义SSID key=自定义密码
2.2 开启热点
netsh wlan start hostednetwork
2.3 关闭热点
netsh wlan stop hostednetwork
2.4 关闭承载网络模式
netsh wlan set hostednetwork mode=disallow
3 连接指定WiFi
3.1 连接已经连接过的WiFi
需要先进行第一步,查看已连接的信息
netsh wlan connect name=SSID名
3.2 连接未连接过的WiFi
Windows保存连接信息的路径为:
C:\ProgramData\Microsoft\Wlansvc\Profiles\Interfaces
该路径下有几个文件夹就代表有几个网卡,每个网卡的文件夹下存放着该网卡的连接信息,连接国几个WiFi就有几个xml文件。
自建连接xml文件
无密码
<?xml version="1.0"?>
<WLANProfile xmlns="http://www.microsoft.com/networking/WLAN/profile/v1">
<name>openwifi</name>
<SSIDConfig>
<SSID>
<hex>6F70656E77696669</hex>
<name>openwifi</name>
</SSID>
</SSIDConfig>
<connectionType>ESS</connectionType>
<connectionMode>manual</connectionMode>
<MSM>
<security>
<authEncryption>
<authentication>open</authentication>
<encryption>none</encryption>
<useOneX>false</useOneX>
</authEncryption>
</security>
</MSM>
<MacRandomization xmlns="http://www.microsoft.com/networking/WLAN/profile/v3">
<enableRandomization>false</enableRandomization>
</MacRandomization>
</WLANProfile>
其中name
标签是要连接的SSID名,hex
标签是SSID的16进制编码。
有密码
<?xml version="1.0"?>
<WLANProfile xmlns="http://www.microsoft.com/networking/WLAN/profile/v1">
<name>securewifi</name>
<SSIDConfig>
<SSID>
<hex>73656375726577696669</hex>
<name>securewifi</name>
</SSID>
</SSIDConfig>
<connectionType>ESS</connectionType>
<connectionMode>manual</connectionMode>
<MSM>
<security>
<authEncryption>
<authentication>WPA2PSK</authentication>
<encryption>AES</encryption>
<useOneX>false</useOneX>
</authEncryption>
<sharedKey>
<keyType>passPhrase</keyType>
<protected>true</protected>
<keyMaterial>010000A4C8309178AC215B示例而已,就不写那么多了,浪费资源6F7F4C5EA9144411481A742DAB052FD789B574</keyMaterial>
</sharedKey>
</security>
</MSM>
<MacRandomization xmlns="http://www.microsoft.com/networking/WLAN/profile/v3">
<enableRandomization>true</enableRandomization>
<randomizationSeed>3894975298</randomizationSeed>
</MacRandomization>
</WLANProfile>
可见与无密码相比,security
标签中多了sharedKey
标签。
创建好后把它放到上文提到的路径
连接指定WiFi
netsh wlan connect name=SSID名