請教
下列方式如何增加包含有密碼的ssid?
netsh wlan add filter permission=allow ssid=tech networktype=infrastructure
謝謝
✅ 假設條件
Wi-Fi 名稱(SSID):
tech
密碼:
mySecretPass
你可以根據需要改掉。
自動連線腳本(儲存為
connect_wifi.bat
)@echo off setlocal REM 設定變數 set SSID=tech set PASSWORD=mySecretPass REM 允許特定 SSID 的連線 netsh wlan add filter permission=allow ssid=%SSID% networktype=infrastructure REM 建立 Wi-Fi 設定檔(臨時 XML) echo ^<!--?xml version="1.0"?^--> > wifi_profile.xml echo ^ >> wifi_profile.xml echo ^<name^>%SSID%^</name^> >> wifi_profile.xml echo ^<ssidconfig^> >> wifi_profile.xml echo ^<ssid^> >> wifi_profile.xml echo ^<name^>%SSID%^</name^> >> wifi_profile.xml echo ^</ssid^> >> wifi_profile.xml echo ^</ssidconfig^> >> wifi_profile.xml echo ^<connectiontype^>ESS^</connectiontype^> >> wifi_profile.xml echo ^<connectionmode^>auto^</connectionmode^> >> wifi_profile.xml echo ^<msm^> >> wifi_profile.xml echo ^<security^> >> wifi_profile.xml echo ^<authencryption^> >> wifi_profile.xml echo ^<authentication^>WPA2PSK^</authentication^> >> wifi_profile.xml echo ^<encryption^>AES^</encryption^> >> wifi_profile.xml echo ^<useonex^>false^</useonex^> >> wifi_profile.xml echo ^</authencryption^> >> wifi_profile.xml echo ^<sharedkey^> >> wifi_profile.xml echo ^<keytype^>passPhrase^</keytype^> >> wifi_profile.xml echo ^<protected^>false^</protected^> >> wifi_profile.xml echo ^<keymaterial^>%PASSWORD%^</keymaterial^> >> wifi_profile.xml echo ^</sharedkey^> >> wifi_profile.xml echo ^</security^> >> wifi_profile.xml echo ^</msm^> >> wifi_profile.xml echo ^ >> wifi_profile.xml REM 匯入 Wi-Fi 設定檔 netsh wlan add profile filename="wifi_profile.xml" REM 嘗試連接 netsh wlan connect name=%SSID% REM 刪除臨時檔案 del wifi_profile.xml echo. echo 完成!正在嘗試連線到 Wi-Fi:%SSID% pause |
🧪 使用方式
打開記事本,貼上上面程式碼
儲存檔案名稱為:
connect_wifi.bat
右鍵以 系統管理員身分執行
