以编程方式在 Windows 中添加带有密码的 wifi 配置文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/35232162/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Add wifi profile with password in windows programmatically
提问by cSteusloff
Is it possible to programmatically add a wifi profile to a windows operating system (minimum version windows 7)?
是否可以以编程方式将 wifi 配置文件添加到 windows 操作系统(最低版本 windows 7)?
I tried netsh with add profileand connect, but it doesn't work for me. Is there any powershell commands which does this?
我尝试了 netsh 与add profile和connect,但它对我不起作用。是否有任何 powershell 命令可以执行此操作?
I want to set a wifi password for a special ssid for many clients automatically.
我想为许多客户端自动设置一个特殊 ssid 的 wifi 密码。
I hope someone has an idea or can give me a command with this sample information:
我希望有人有想法或可以给我一个包含此示例信息的命令:
- SSID: WifiNetwork
- Password: Password123
- SSID:无线网络
- 密码:Password123
Thanks
谢谢
回答by cSteusloff
I found a way to add a wifi profile.
我找到了一种添加 wifi 配置文件的方法。
At first you export an existing wifi profile:
首先,您导出现有的 wifi 配置文件:
netsh wlan export profile name="WifiNetwork" folder="C:\path\" key=clear
Than you get a XML file with the following style:
然后你得到一个具有以下样式的 XML 文件:
<?xml version="1.0"?>
<WLANProfile xmlns="http://www.microsoft.com/networking/WLAN/profile/v1">
<name>WifiNetwork</name>
<SSIDConfig>
<SSID>
<hex>576966694E6574776F726B</hex>
<name>WifiNetwork</name>
</SSID>
</SSIDConfig>
<connectionType>ESS</connectionType>
<connectionMode>auto</connectionMode>
<MSM>
<security>
<authEncryption>
<authentication>WPA2PSK</authentication>
<encryption>AES</encryption>
<useOneX>false</useOneX>
</authEncryption>
<sharedKey>
<keyType>passPhrase</keyType>
<protected>false</protected>
<keyMaterial>Password123</keyMaterial>
</sharedKey>
</security>
</MSM>
</WLANProfile>
Than you can modify this file and import it to add this wifi with this command:
您可以修改此文件并将其导入以使用以下命令添加此 wifi:
netsh wlan add profile filename="C:\path\WifiNetwork.xml"
Check your profiles with:
检查您的个人资料:
netsh wlan show profile
I hope I could help someone with this information.
我希望我可以帮助有人提供这些信息。