หากใช้ VPN ทุกวัน ตั้งค่า Auto-connect ตอน Boot จะสะดวก ไม่ต้องเปิดแอปกด Connect เอง macOS ไม่มีตัวเลือก Built-in แต่ทำได้ด้วย AppleScript
สร้างแอปจาก AppleScript สำหรับเชื่อม VPN
- เปิด Script Editor (Launchpad ค้นหา)
- File → New
- วางสคริปต์ด้านล่าง (แทนที่ "MYVPNServer" ด้วยชื่อ VPN ของคุณ):
on idle tell application "System Events" tell current location of network preferences set myVPN to the service "MYVPNServer" if myVPN is not null then if current configuration of myVPN is not connected then connect myVPN end if end if end tell return 60 end tell end idle
- File → Save... → File Format: Application → ติ๊ก "Stay open after run handler" → Save
เพิ่มแอป VPN เข้า Login Items
- Apple Menu → System Preferences
- Users & Groups → บัญชีของคุณ → Login Items
- กด + → เลือกแอปที่สร้าง → Add
- แอปจะอยู่ในรายการ → รันอัตโนมัติตอน Boot → เชื่อม VPN
สรุป
ใช้ AppleScript สร้างแอปเชื่อม VPN ใส่ Login Items จะเชื่อมต่ออัตโนมัติทุกครั้งที่เปิดเครื่อง