本帖最后由 went 于 2020-3-11 17:44 编辑
- @echo off
- powershell -c "Get-Content -LiteralPath '%~0' | Select-Object -Skip 3 | Out-String | Invoke-Expression"
- pause&exit
- $wifiName="CMCC-Z"; # WIFI NAME
- $wifiKey="12345678"; # WIFI PASSWORD
- $xml_Template=@"
- <?xml version="1.0"?>
- <WLANProfile xmlns="http://www.microsoft.com/networking/WLAN/profile/v1">
- <name>WIFI_NAME</name>
- <SSIDConfig>
- <SSID>
- <hex>WIFI_NAME_HEX</hex>
- <name>WIFI_NAME</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>false</protected>
- <keyMaterial>WIFI_KEY</keyMaterial>
- </sharedKey>
- </security>
- </MSM>
- <MacRandomization xmlns="http://www.microsoft.com/networking/WLAN/profile/v3">
- <enableRandomization>false</enableRandomization>
- <randomizationSeed>634562794</randomizationSeed>
- </MacRandomization>
- </WLANProfile>
- "@
- $wifiNameHex="";
- foreach ($each in [System.Text.Encoding]::UTF8.GetBytes($wifiName)) { $wifiNameHex+=("{0:x}" -f $each).ToUpper();}
- $xmlFile="WLAN-{0}.xml" -f $wifiName
- $xml=$xml_Template -replace "WIFI_NAME_HEX",$wifiNameHex -replace "WIFI_NAME",$wifiName -replace "WIFI_KEY",$wifiKey
- $xml | Out-File $xmlFile -Encoding utf8
- netsh wlan delete profile $wifiName 2>$null
- netsh wlan add profile $xmlFile
- netsh wlan connect $wifiName
- Remove-Item -LiteralPath $xmlFile
复制代码 电脑win10
默认加密方式WPA2PSK,如果是其它的你改一下21行看看能不能正常连接 |