matomo

Using Viscosity for Windows

David Wibergh, about Products & features

Viscosity is an OpenVPN client for macOS and Windows offering many user-friendly functionalities. The client is not free and costs $9. However, we definitely think it’s worth it. If you are not convinced, you can always use it for a trial period of 30 days to test it without any commitment.

This guide will explain how you can get the maximum utility of the features that Viscosity has to offer.
I will show you how you can shut down applications if the VPN connection should stop working, how you can simply import several configuration files, and lastly how to prevent data leakages.

First of all, you need to download the Viscosity client. You can find the download link on their official website. You can choose to download the client for Mac or Windows depending on your OS. Note that this guide has been dedicated to using Viscosity on Windows). However, the same functionalities can be set up for macOS.

After completing the installation process, you simply run Viscosity and make sure that you don’t have another VPN client running at the same time. You should also make sure you’ve downloaded our configuration files and have them ready. If you want to connect to OVPN, it’s recommended that you download all available configuration files from us.

To import a connection is very simple. Just click the plus sign in the lower-left corner and choose “Import connection” >” From file…” and then choose your OVPN configuration file.
viscosity-import-from-file

If you wish, you can import all OVPN configuration files and change the file names to the name of the server that uses it. This should look something like this:
viscosity-import

Remember to let all your traffic go through the VPN connection! Go to the “Networking" tab and check the box called "Send all traffic over VPN connection."

(1.) Run Viscosity on login.

You can configure Viscosity to run on login or computer startup. You can also customize Viscosity so that it connects to the most recently used server.
You’ll do this by setting up “Start Viscosity at login” and “Reconnect active connections on wake”. The settings should be as the picture below:
Run Viscosity on startup

In order to automatically connect to a server when running Viscosity, find the connection you want to edit and right-click on it and choose "Edit." Then check the box called “Connect when Viscosity opens,” which can be found on the bottom of the page.

(2.) Exit specified applications if the VPN connection is terminated.

One of the best features of Viscosity is that you can choose to run certain scripts if your VPN connection is temporarily lost or terminated. You can set this up for virtually any application, but perhaps the most common use of this feature is for a torrent client.

In order to accomplish this, you need to right-click on the connection you want to run the exit script for and choose “Edit.” Then click the “Advanced” tab and choose to add script within Disconnected Script. It should look like this:

Viscosity script kill program

We’ve provided a script for this purpose that will run if you lose your VPN connection:

   Dim objWMIService, objProcess, colProcess 
   Dim strProcessKill
   strProcessKill = array("notepad.exe", "utorrent.exe", "vuze.exe")
   For Each Process In strProcessKill
   Dim strComputer : strComputer = "." 
   
   Set objWMIService = GetObject("winmgmts:" _ 
      & "{impersonationLevel=impersonate}!\\" _ 
         & strComputer & "\root\cimv2") 
   
   Set colProcess = objWMIService.ExecQuery _
   ("SELECT commandline FROM Win32_Process WHERE commandline LIKE '%" & Process & "%'")  
   
   For Each objProcess In colProcess 
        objProcess.Terminate() 
   Next 
   Next

You don’t need to worry about the code here except for this line:
strProcessKill = array("notepad.exe", "utorrent.exe", "vuze.exe")
as this is the line specifying which application that should be closed if and when you lose your VPN connection. Note that you can specify several applications here.

Once you’ve chosen which applications to be closed when the VPN connection is lost, save the file as “OVPN-avsluta.vbs”.

(3.) Terminate your Internet connection if your VPN connection is lost.

This fully prevents your real IP address from being shown in the case of you losing your VPN connection. Usually, Windows will use the ordinary adapter if you lose your VPN connection. In order for you to stay protected, we want to prevent this from happening using another *Disconnected Script”.

Just like before, you should go to Disconnected Scripts and enter the following script:

Dim objShell

Set objShell = WScript.CreateObject ("WScript.shell")

objShell.run "cmd /K netsh interface set interface name='Ethernet' admin=disabled"

Set objShell = Nothing

In effect, this script tells Windows to set your network adapter to “Disabled” when the VPN connection is lost, which in turn terminates your Internet connection.
In order for this to work properly, please make sure of the following:

  • That you run Viscosity as administrator
  • Check that the networking adapter is correctly entered

To find the exact name of your networking adapter, go to Control Panel -> Network and Internet -> Network Connections
It should look like this:
ethernet

In order to enable your Internet connection again, you need to enable your networking adapter. You can do this manually by going to network settings. An easier solution is to make a BAT-file and place it on your desktop that can be run as administrator:
netsh interface set interface name=""Ethernet"" admin=enable"

(4.) Terminate the Internet connection as well as specified applications if your VPN connection is lost.

Copy the code from step 3 and put the code from step 2 on the bottom.

(5.) Make sure everything works.

It’s always recommended that everything works as intended. You can run the following tests:

  • Test the termination scripts by right-clicking and choosing “Disconnect”.
  • Go to our dashboard to see that you're connected properly and don't have any DNS leaks

(6.) Conclusion

This has been a short guide showing you how to explore the functionalities of Viscosity. Viscosity is a great alternative if you wish to use more advanced VPN features.

If you’ve followed the steps in this guide, you should now have a VPN client that terminates your Internet connection as well as close specified applications if your VPN connection is lost.

David Wibergh