SHARE
TWEET

Untitled

a guest May 21st, 2019 293 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- Install your VPN client, configure, and connect
  2. -- Launch Script Editor
  3. -- New Document
  4. -- Paste the contents of this script in editor
  5. -- Save
  6. -- * Save As: AutoConnectVpnOnStartup
  7. -- * Where: Applications
  8. -- * File Format: Application
  9. -- * Unchecked Show startup screen
  10. -- * Unchecked Stay open after run handler
  11. -- * Save
  12. -- Add to startup
  13. -- * Launch System Preferences
  14. -- * Users & Groups
  15. -- * Select your user
  16. -- * Login Items
  17. -- * Click + sign
  18. -- * Highlight /Applications/AutoConnectVpnOnStartup.app
  19. -- * Click Add
  20. -- Grant permissions
  21. -- * From System Preferences
  22. -- * Security & Privacy
  23. -- * Accessibility
  24. -- * Click + sign
  25. -- * Highlight /Applications/AutoConnectVpnOnStartup.app
  26. -- * Click Open
  27. -- Restart
  28. -- The first time, you will be prompted to grant permission for Automation and System Events; allow
  29. -- Restart
  30. -- NOTE: You may tune the delay below based on the speed of your startup.
  31.  
  32.  
  33. delay 15
  34.  
  35. -- First, turn on VPN menu
  36. do shell script "defaults write com.apple.systemuiserver menuExtras -array-add \"/System/Library/CoreServices/Menu Extras/VPN.menu\""
  37. do shell script "killall SystemUIServer"
  38. delay 2
  39.  
  40. -- Now use menu to connect if needed
  41. tell application "System Events"
  42.     tell process "SystemUIServer"
  43.         set vpnMenu to (menu bar item 1 of menu bar 1 where description is "VPN")
  44.         tell vpnMenu to click
  45.         if ((first menu item of menu 1 of vpnMenu where its title starts with "Connect ") exists) then
  46.             click (first menu item of menu 1 of vpnMenu where its title starts with "Connect ")
  47.         else
  48.             key code 53
  49.         end if
  50.     end tell
  51. end tell
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top