on idle tell application “System Events” tell current location of network preferences set myVPN to the service “VPN NAME” 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
4. 將上文中 VPN NAME 取代為你在網絡設定中為你的 VPN 連線所起的名字(在這例子中的名字是「 My Home VPN (L2TP) 」)。你也可以修改上文中「 return 60 」,將 60 改為更少的數字來加密檢查連線的時間(單位是秒)。
5. 按「 Command S 」打開儲存對話框,「 File Format 」選擇「 Application 」,勾選「 Stay open after run handler 」,「 Where 」選擇一個儲存地方,例如是你的用戶 User 資料夾(這例是放在 Desktop ),隨便蓋個名字來儲存便可以(這例子是 AutoVPN )。
6. 進入「 System Preferences 」,選擇「 Users & Groups 」,在左邊選擇你自己的帳戶,在右邊上方選擇「 Login Items 」。