天天看點

win10自動連接配接WIFI的批處理檔案環景:

環景:

聯想計算機

win10專業版

電腦之前從未連接配接過這個WIFI

批處理檔案内容如下(不全):

全檔案

@echo off

powershell -c “Get-Content -LiteralPath ‘%~0’ | Select-Object -Skip 3 | Out-String | Invoke-Expression”

pause&exit

set-ExecutionPolicy RemoteSigned

$wifiName=“你的ssid”; # WIFI NAME

$wifiKey=“你的password”; # WIFI PASSWORD

$xml_Template=@"

<?xml version="1.0"?> WIFI_NAME WIFI_NAME_HEX WIFI_NAME ESS manual WPA2PSK AES false passPhrase false WIFI_KEY false 634562794 "@ $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

預設加密方式WPA2PSK,如果是其它的,改一下21行看看能不能正常連接配接

繼續閱讀