天天看点

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行看看能不能正常连接

继续阅读