Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Install your VPN client, configure, and connect
- -- Launch Script Editor
- -- New Document
- -- Paste the contents of this script in editor
- -- Save
- -- * Save As: AutoConnectVpnOnStartup
- -- * Where: Applications
- -- * File Format: Application
- -- * Unchecked Show startup screen
- -- * Unchecked Stay open after run handler
- -- * Save
- -- Add to startup
- -- * Launch System Preferences
- -- * Users & Groups
- -- * Select your user
- -- * Login Items
- -- * Click + sign
- -- * Highlight /Applications/AutoConnectVpnOnStartup.app
- -- * Click Add
- -- Grant permissions
- -- * From System Preferences
- -- * Security & Privacy
- -- * Accessibility
- -- * Click + sign
- -- * Highlight /Applications/AutoConnectVpnOnStartup.app
- -- * Click Open
- -- Restart
- -- The first time, you will be prompted to grant permission for Automation and System Events; allow
- -- Restart
- -- NOTE: You may tune the delay below based on the speed of your startup.
- delay 15
- -- First, turn on VPN menu
- do shell script "defaults write com.apple.systemuiserver menuExtras -array-add \"/System/Library/CoreServices/Menu Extras/VPN.menu\""
- do shell script "killall SystemUIServer"
- delay 2
- -- Now use menu to connect if needed
- tell application "System Events"
- tell process "SystemUIServer"
- set vpnMenu to (menu bar item 1 of menu bar 1 where description is "VPN")
- tell vpnMenu to click
- if ((first menu item of menu 1 of vpnMenu where its title starts with "Connect ") exists) then
- click (first menu item of menu 1 of vpnMenu where its title starts with "Connect ")
- else
- key code 53
- end if
- end tell
- end tell
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement