Trouble with Applescript/Xcode setting up VPN Auto Connect with Btguard’s Tunnelblick Open VPN

applescriptvpn

I followed all of the all of the steps in this link How to auto connect to VPN upon login/boot?. I tried a number of times, changing the service from "BTGuard VPN" to "Tunnelblick VPN" to "BTGuard", etc., without success. I keep getting this notice from Applescript:

"Can't get <<class svce>> "btguard" of <<class locc>> of <<class netp>> of application "System Events".

I am running Mac 10.8.4 and am using BTGuard's Open VPN service via the Tunnelblick app. Also, my OS can't hide the extension, thus it appears as an app.

Best Answer

"System Events" is an Apple-supplied function. It can only be used to start a VPN that is the type of VPN built into OS X -- an "L2TP over IPSec" or "PPTP", or "Cisco IPSec" VPN.

Tunnelblick is used to start/stop/manage an "OpenVPN" VPN, which is different. (That is why you need Tunnelblick to use the VPN -- OS X does not include software to handle an OpenVPN-based VPN.)

Tunnelblick itself has an option to start when the computer starts -- on the "Settings" tab of the "Configurations" panel of the "VPN Details..." window, there is a setting named "Connect". The default setting is "Manually", but you can set it to connect "When Tunnelblick launches" or "When computer starts".

The "When computer starts" setting will only be available if the configuration is what Tunnelblick calls a "Shared" configuration, or if the version of Tunnelblick you have is what is called a "Deployed" version (with the configurations built into the application).

If you have a "Private" configuration, you can change it to "Shared" (and thus enable the "When computer starts" setting) by selecting the configuration in the list on the left, then clicking the little "gear" icon at the bottom of the list, then clicking "Make Configuration Shared..."

Even with "When computer starts" selected, there is a time during the computer startup when the VPN has not been established but network operations take place (among other things, to start the VPN!), so there is network traffic that is not sent through the VPN. If you are trying to make sure nobody can "eavesdrop" on your network connection, this brief time period is a time when they can.

For that reason, few people use the "When computer starts" option -- and it could be buggy (I speak as the developer/maintainer of Tunnelblick). It is likely that selecting "When Tunnelblick launches" and have Tunnelblick launch when you log in will be sufficient for your needs. Tunnelblick will launch when you log in if it is running when you log out (or shut down or restart). And when it launches, it will start the VPN if it is set to "When Tunnelblick launches".

If you have further questions about using Tunnelblick, please use Tunnelblick's Discussion Group for questions -- https://groups.google.com/forum/#!forum/tunnelblick-discuss.