Protect Mac OS X applications from accessing the Internet when PPTP reconnects

Certain applications should only run if a VPN connection is active, e.g. uTorrent or Transmission. This howto describes how to set up an AppleScript on Mac OS X to monitor the availability of a PPTP connection, reconnect if it fails and to open or close a certain application accordingly.

Download MacOSXProtector.applescript and open it in the AppleScript Editor. The script is prepared to work with uTorrent, but it can easily be adapted to protect any other application. You need to change the variable myProtectedApplication, e.g. set it to Transmission.

After having done your changes, open the File menu and click Save as …. First set the File Format to Application. From the Options, check Stay Open. Alter the new applications name and have it save on your Desktop for easy access.

You will find the new application on your Desktop. Start it. If your PPTP connection was turned inactive, it will be turned started. If the application was closed, it will be opened as well. Should the PPTP connection now fail, the application will be closed and PPTP will be reconnected.

As long as (or however you named it) keeps running, the configured application is protected from accessing the Internet without going through the PPTP connection.