Windows: Kill μTorrent if your VPN service is disconnected

David Wibergh, about Online Privacy

This guide will show you how you can easily set μTorrent to shutdown if your connection to OVPN is lost at any time. This guide pertains specifically to Windows 7, 8 and 8.1.

1. Run Powershell

Most likely, you haven’t run Powershell before. If so, you first need to find where powershell is located. Usually it can be found here:


The file name is powershell.exe. Right-click the file and choose Run as administrator. Then enter:

Set-ExecutionPolicy unrestricted

You will now see a message asking if you are sure that you want to execute the command. Press Y to confirm that you wish to do so.

2. Download the application

Download our script.

Put the downloaded file to the config directory that is usually found at:

C:\Program Files\OpenVPN\config


C:\Program Files (x86)\OpenVPN\config

Right-click monitorvpn.ps1, and open the file with a text editor.

If μTorrent has been installed in another path than C:\Program Files (x86)\uTorrent\uTorrent.exe, you need to edit the following line in the script:

$ClientExecutable = "C:\Program Files (x86)\uTorrent\uTorrent.exe" 	# Full path to client executable

Instead of the stated path, you will need to write the path you use for μTorrent. You also need to edit this line if you use another torrent client than μTorrent.

If the config file you use is not named OVPN - Sverige.ovpn, you also need to edit this line:

$Configfile = "$OpenVpnPath\config\OVPN - Sverige.ovpn"			# The name of the OVPN config file. Multiple configs may be used, see function ConnectVPN to enable.

and simply replace OVPN - Sverige.ovpn with the name of the file you are using.

If you are connected to OVPN when doing this, you need to disconnect temporarily in order to find your local gateway. Once disconnected from OVPN, do the following:

Open the Command prompt, and type


A number of lines will appear after entering this command. The first line will probably look something like this:

 1 (  2.174 ms  1.339 ms  0.961 ms

This means that your local gateway is Note that if you have something else on your first line, you should use that one instead going forward.

Copy the IP address and change:

$myLocalGateway = ""


$myLocalGateway = ""

3. Create a shortcut

Go to your desktop and Right-click anywhere » New » Shortcut.

Enter powershell.exe -file "C:\Program Files\OpenVPN\config\monitorvpn.ps1" as the file path for the shortcut.

If you have another file path, make sure to write this instead.

Then click Next.

Enter OVPN - Control uTorrent as the shortcut name.

4. Done!

Double-click OVPN – Control uTorrent that should now be on your desktop. A Command prompt window will appear, which constantly checks your connection to OVPN.

Important notes

The script checks the connection to OVPN every five seconds. Thus, μTorrent won’t always be shut down instantaneously if the OVPN connection is lost. The worst-case scenario would be that uTorrent is open for five seconds before shutting down in these cases.

To decrease the connection check time to less than five seconds, change the following line in the script:

$Sleeptime = 5								# Number of seconds to wait before running connection status checks again

Change the value of $SleepTime to be less than five if you wish.

Thank you, Sture887!

This script was programmed by Sture887 on Flashback. Thank you, Sture887, for taking the time to customize this script for OVPN.

David Wibergh