以编程方式在 windows 中添加带有密码的 wifi 配置文件
Add wifi profile with password in windows programmatically
是否可以通过编程方式将 wifi 配置文件添加到 windows 操作系统(最低版本 windows 7)?
我尝试使用 add profile 和 connect 的 netsh,但它对我不起作用。是否有执行此操作的任何 powershell 命令?
我想为很多客户端自动设置一个特殊ssid的wifi密码。
我希望有人有想法或可以给我一个带有此示例信息的命令:
- SSID:Wifi 网络
- 密码:Password123
谢谢
我找到了添加 wifi 配置文件的方法。
首先导出现有的 wifi 配置文件:
netsh wlan export profile name="WifiNetwork" folder="C:\path\" key=clear
你会得到一个具有以下样式的 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>
然后您可以修改此文件并导入它以使用此命令添加此 wifi:
netsh wlan add profile filename="C:\path\WifiNetwork.xml"
检查您的个人资料:
netsh wlan show profile
检查您的个人资料密钥:
netsh wlan show profiles WifiNetwork key=clear
我希望我能用这些信息帮助别人。
我写了一个强大的 shell 脚本 - 以下代码中的前三行还没有像在我的脚本中那样经过测试 我从 CSV 文件中获取它 - 其余的是原样 - 并且在两个上工作我拥有的 SSId
$profilefile="ACprofile.xml"
$SSID="ACSSID"
$PW="12345678"
$SSIDHEX=($SSID.ToCharArray() |foreach-object {'{0:X}' -f ([int]$_)}) -join''
$xmlfile="<?xml version=""1.0""?>
<WLANProfile xmlns=""http://www.microsoft.com/networking/WLAN/profile/v1"">
<name>$SSID</name>
<SSIDConfig>
<SSID>
<hex>$SSIDHEX</hex>
<name>$SSID</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>$PW</keyMaterial>
</sharedKey>
</security>
</MSM>
</WLANProfile>
"
$XMLFILE > ($profilefile)
netsh wlan add profile filename="$($profilefile)"
netsh wlan show profiles $SSID key=clear
netsh wlan connect name=$SSID
是否可以通过编程方式将 wifi 配置文件添加到 windows 操作系统(最低版本 windows 7)?
我尝试使用 add profile 和 connect 的 netsh,但它对我不起作用。是否有执行此操作的任何 powershell 命令?
我想为很多客户端自动设置一个特殊ssid的wifi密码。
我希望有人有想法或可以给我一个带有此示例信息的命令:
- SSID:Wifi 网络
- 密码:Password123
谢谢
我找到了添加 wifi 配置文件的方法。
首先导出现有的 wifi 配置文件:
netsh wlan export profile name="WifiNetwork" folder="C:\path\" key=clear
你会得到一个具有以下样式的 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>
然后您可以修改此文件并导入它以使用此命令添加此 wifi:
netsh wlan add profile filename="C:\path\WifiNetwork.xml"
检查您的个人资料:
netsh wlan show profile
检查您的个人资料密钥:
netsh wlan show profiles WifiNetwork key=clear
我希望我能用这些信息帮助别人。
我写了一个强大的 shell 脚本 - 以下代码中的前三行还没有像在我的脚本中那样经过测试 我从 CSV 文件中获取它 - 其余的是原样 - 并且在两个上工作我拥有的 SSId
$profilefile="ACprofile.xml"
$SSID="ACSSID"
$PW="12345678"
$SSIDHEX=($SSID.ToCharArray() |foreach-object {'{0:X}' -f ([int]$_)}) -join''
$xmlfile="<?xml version=""1.0""?>
<WLANProfile xmlns=""http://www.microsoft.com/networking/WLAN/profile/v1"">
<name>$SSID</name>
<SSIDConfig>
<SSID>
<hex>$SSIDHEX</hex>
<name>$SSID</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>$PW</keyMaterial>
</sharedKey>
</security>
</MSM>
</WLANProfile>
"
$XMLFILE > ($profilefile)
netsh wlan add profile filename="$($profilefile)"
netsh wlan show profiles $SSID key=clear
netsh wlan connect name=$SSID