App Support.

We're here to help.



Controlling Viscosity with Scripting (Windows)

As of Viscosity Windows 1.4.5, Viscosity provides support to be able to control connections using scripting. Scripting enabled you to take actions depending on the state of one of several connections, get information about connections, and control connections external to Viscosity's GUI.

Batch scripting is controlled using the included binary ViscosityCC.exe, allowing for feedback to Command Line.

ViscosityCC Commands

ViscosityCC.exe can be found in your default installation directory, generally C:\Program Files\Viscosity\ViscosityCC.exe.

Connect A Connection By Name

ViscosityCC.exe connect "My Connection"

Disconnect A Connection By Name

ViscosityCC.exe disconnect "My Connection"

Display Name Of The First Connection

ViscosityCC.exe getname 1

Display State Of The First Connection

ViscosityCC.exe getstate 1

Display State Of Connection By Name

ViscosityCC.exe getstate "My Connection"

Batch (.bat) Examples

Several example can be found below for Batch scripting.

Connect And Open Webpage Once Connected

@echo off
REM Example Viscosity Batch script to connect the fourth connection,
REM Wait until the connection has connected,
REM And then open a webpage
set ViscosityCCPath="C:\Program Files\Viscosity\ViscosityCC.exe"
set state=
set connname=
REM Get the 4th connections name
for /f "delims=" %%a in ('"%ViscosityCCPath% getname 4"') do @set connname=%%a
echo %connname%
REM Check the connection is not already started
for /f "delims=" %%a in ('"%ViscosityCCPath% getstate "%connname%""') do @set state=%%a
echo %state%
if NOT %state%==Disconnected goto :loop
REM Start the connection
%ViscosityCCPath% connect "%connname%"
REM Sleep 10 seconds to allow the connection to happen
PING 127.0.0.1 -n 8 -w 60000 >NUL
set state=Connecting
 :loop
PING 127.0.0.1 -n 2 -w 60000 >NUL
for /f "delims=" %%a in ('"%ViscosityCCPath% getstate "%connname%""') do @set state=%%a
echo %state%
if NOT %state%==Connected goto :loop
 :connected
start http://www.sparklabs.com/support