Created
July 18, 2016 08:39
-
-
Save prasanthj/6749954dcfbab838242a0c36341d81d1 to your computer and use it in GitHub Desktop.
VPN auto-connect OS X El Capitan (Run this from Script Editor)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set vpn_name to "'VPN_NAME'" | |
tell application "System Events" | |
set rc to do shell script "scutil --nc status " & vpn_name | |
if rc starts with "Connected" then | |
do shell script "scutil --nc stop " & vpn_name | |
else | |
-- get current clipboard contents as a string | |
set CurrentClipboard to the clipboard as string | |
-- set the clipboad to your password | |
set the clipboard to "VPN_PASSWORD" | |
do shell script "scutil --nc start " & vpn_name | |
delay 2 | |
-- paste clipboard contents into password box | |
keystroke "v" using {command down} | |
-- press "Enter" | |
keystroke return | |
-- wait 2 seconds to connect | |
delay 2 | |
-- now reset the clipboard to what it was before we started | |
set the clipboard to CurrentClipboard | |
end if | |
end tell |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment