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

Certain applications should only run if a VPN connection is active, e.g. uTorrent or Transmission. This howto describes how to achieve this with two AppleScripts on Mac OS X and Viscosity.

Download MacOSXRunProtectedApplication.applescript and MacOSXQuitProtectedApplication.applescript.

Open MacOSXRunProtectedApplication.applescript in the AppleScript Editor and change myProtectedAppliction to the protected application's name, e.g. Transmission and save your changes. This example is made to work with uTorrent.

Now open MacOSXQuitProtectedApplication.applescript and repeat the previous step.

Next, open Viscosity's preferences, select the appropriate connection and edit it. Switch to the Advanced tab. Point the Connected Script to MacOSXRunProtectedApplication.applescript and the Disconnect Script to MacOSXQuitProtectedApplication.applescript.

With this combination of scripts set up in Viscosity, the application referenced as myProtectedApplication will be protected from being run when the VPN is disconnected.