手中的剑为什么而挥动
只有靠你自己去寻找答案----盖聂

bat-win10自动连接WIFI的批处理-bat

备用下载:1、000124-01-更新-2022-08-28

@echo off
powershell -c "Get-Content -LiteralPath '%~0' | Select-Object -Skip 3 | Out-String | Invoke-Expression" 
pause&exit
$wifiName="这里写WiFi名字"; # WIFI NAME
$wifiKey="这里写密码"; # 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
赞(0) 打赏
未经允许不得转载: » bat-win10自动连接WIFI的批处理-bat
分享到

觉得文章有用就打赏一下文章作者

非常感谢你的打赏,我们将继续提供更多优质内容,让我们一起创建更加美好的网络世界!

支付宝扫一扫

微信扫一扫