Skip to content

Instantly share code, notes, and snippets.

@kristopherjohnson
Last active December 8, 2015 19:15
Show Gist options
  • Select an option

  • Save kristopherjohnson/9a1c42cbdbc9472ad8a1 to your computer and use it in GitHub Desktop.

Select an option

Save kristopherjohnson/9a1c42cbdbc9472ad8a1 to your computer and use it in GitHub Desktop.
AppleScript app to keep VPN connection open
on idle
tell application "System Events"
set vpn_name to "'My VPN'"
set rc to do shell script "scutil --nc status " & vpn_name
if rc does not start with "Connected" then
do shell script "scutil --nc start " & vpn_name
end if
end tell
return 120
end idle
@kristopherjohnson
Copy link
Author

Replace "My VPN" with the name of your VPN (as set up in System Preferences > Network). save this AppleScript as an application and run it. Every two minutes, it will check whether that VPN is connected, and if not, re-establish the connection.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment