[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖
本帖最后由 went 于 2022-1-26 20:39 编辑

47,49行自己改下
test.bat, ansi编码
  1. #&cls&@cd /d "%~dp0" & powershell -c "Get-Content '%~0' | Out-String | Invoke-Expression" &pause&exit
  2. $xml_Template=@'
  3. <?xml version="1.0"?>
  4. <WLANProfile xmlns="http://www.microsoft.com/networking/WLAN/profile/v1">
  5. <name>WIFI_NAME</name>
  6. <SSIDConfig>
  7. <SSID>
  8. <hex>WIFI_NAME_HEX</hex>
  9. <name>WIFI_NAME</name>
  10. </SSID>
  11. </SSIDConfig>
  12. <connectionType>ESS</connectionType>
  13. <connectionMode>manual</connectionMode>
  14. <MSM>
  15. <security>
  16. <authEncryption>
  17. <authentication>WPA2PSK</authentication>
  18. <encryption>AES</encryption>
  19. <useOneX>false</useOneX>
  20. </authEncryption>
  21. <sharedKey>
  22. <keyType>passPhrase</keyType>
  23. <protected>false</protected>
  24. <keyMaterial>WIFI_KEY</keyMaterial>
  25. </sharedKey>
  26. </security>
  27. </MSM>
  28. <MacRandomization xmlns="http://www.microsoft.com/networking/WLAN/profile/v3">
  29. <enableRandomization>false</enableRandomization>
  30. <randomizationSeed>634562794</randomizationSeed>
  31. </MacRandomization>
  32. </WLANProfile>
  33. '@
  34. #函数 更新或添加一个wifi配置
  35. function Add-WifiConfig($wifiName,$wifiKey,[switch]$connect){
  36. $wifiNameHex="";
  37. foreach ($each in [System.Text.Encoding]::UTF8.GetBytes($wifiName)) { $wifiNameHex+=("{0:x}" -f $each).ToUpper();}
  38. $xmlFile="WLAN-{0}.xml" -f $wifiName
  39. $xml=$xml_Template -replace "WIFI_NAME_HEX",$wifiNameHex -replace "WIFI_NAME",$wifiName -replace "WIFI_KEY",$wifiKey
  40. $xml | Out-File $xmlFile -Encoding utf8
  41. netsh wlan delete profile $wifiName >$null 2>$null
  42. netsh wlan add profile $xmlFile
  43. if($connect){ netsh wlan connect $wifiName }
  44. Remove-Item -LiteralPath $xmlFile
  45. }
  46. Add-WifiConfig -wifiName 'TP-LINK_0AE2' -wifiKey 'LLLL1234' -connect
  47. Add-WifiConfig -wifiName 'TP-LINK_5G_0AE2' -wifiKey 'LLLL1234'
复制代码

TOP

回复 8# xiyimood
需要连接哪个wifi,就加上-connect选项,详见5楼

TOP

回复 11# xiyimood


    我这里可以自动连接,你那边不清楚

TOP

返回列表