Viscosity. OpenVPN client. For Mac.  
 
 

Search

Search our Knowledge Base to see if we already have an answer for your question:

Search

Browse KB

Browse articles in our Knowledge Base by category:

Browse

Viscosity Windows

Other articles in this category:

Getting Started With Viscosity (Windows)
Installing Viscosity for Windows
Uninstalling Viscosity for Windows
Bundling Viscosity for Windows with VPN Connections & Preferences
Running Batch/VBS Scripts when Connected/Disconnected in Viscosity for Windows
Registering Viscosity

 

Running Batch/VBS Scripts when Connected/Disconnected in Viscosity for Windows
Knowledge Base > Viscosity Windows > Running Batch/VBS Scripts when Connected/Disconnected in Viscosity for Windows


Viscosity allows you to run custom Batch (.bat) or Visual Basic/VBS (.vbs) scripts when your connection connects or disconnects. This can allow you to automate common tasks, such as connecting to file servers, opening web pages, opening applications, and controlling any application that is scriptable in Batch or VBS.

Selecting Scripts To Use

Viscosity makes it easy to specify scripts to run when a connection connects or disconnects, and allows you to specify different scripts for each connection. You can specify a script like so:

  1. Open Viscosity's Preferences window
  2. Select the connection you wish to add a script to and click the Edit button
  3. Click the Advanced tab


  4. If you'd like a script to run when your VPN connection becomes connected, click the Select button next to the "Connected Script" field. Likewise, if you want your script to run when your connection becomes disconnected, click the Select button next to the "Disconnected Script" field.


Writing Scripts

Writing scripts in Windows is quite simple. Follow the instructions below to create a script.

  1. Open notepad by going to Start->Programs->Accessories->Notepad
  2. A new blank window should appear. Enter the the following as a simple script:

    MsgBox "Hello There!"


  3. Go to File->Save.
  4. Change the "Save as type:" to All Files, and enter a name for your file followed by .vbs. If you are creating a Batch script, append .bat instead.


  5. Test the script by double clicking it where you saved it.

Common Tasks

The following are example VBS or Batch script snippets for common tasks. These can be combined to create your Connected/Disconnected scripts.

Mount a Network Drive

The following Batch script can be used to mount a network drive to a remote file server. 'Z:' can be changed to any drive letter you require. Place the following code in your Connected script.

@echo off
net use Z: \\server\share

Place the following code in your Disconnected script to disconnect the network drive when the VPN connection is terminated.

@echo off
net use Z: /delete

Display A Message To The User

The following VBS script can be used to display a message to the user when they connect. It could be used to display a welcome message, instructions or even Terms of Use for your service. Place the following code in your Connected Script.

MsgBox "Hello There!"

Open A Webpage

The following VBS script will automattically open the user's default web browser and go to the specified web page. This could be used to automatically open a company's Intranet webpage, display a welcome webpage, etc.

URL = "http://www.thesparklabs.com"
Set objShell = CreateObject("Wscript.Shell")
objShell.Run(URL)







 
 
Navigate

Home
Applications
Blog
About
Support
  Support

Support Home
Documentation
Knowledge Base
Forum
  Community

Blog
Forum
Twitter
Viscosity
Viscosity Server


 
 
SparkLabs Copyright © SparkLabs. All Rights Reserved.