VBScript 1.1.0
This example demonstrates how to make use of Persistent Variables in a WSF (Windows Scripting Host File) file, i.e. a VBScript file.
You will find it in the download package in the following folder
- \examples\External\vbs
This little script is meant to be connected with a shortcut SwyxIt! skin element. By clicking on that shortcut the .wsf file will be started.
By starting this .wsf file the current status of the installed Night Switch will be toggled.
Toggle.wsf
<package> <job id="Toggle_Example"> <script language="VBScript" src="PersistentVariables.vbs"/> <script language="VBScript"> ' configure the complete db connect string g_sPersistentVariableConnectString = _ "Provider=sqloledb;" & _ "Data Source=WS-WELLIGE04;" & _ "Initial Catalog=" & PERSISTENT_VARIABLE_DATABASE & ";" & _ "User Id=PersistentVariables;" & _ "Password=PersistentVariables" ' initialize persistent variable Dim NightSwitch Set NightSwitch = new PersistentVariable NightSwitch.Name = "NightSwitch" NightSwitch.Default = 0 if NightSwitch.Value = 0 then NightSwitch.Value = 1 else NightSwitch.Value = 0 end if Set NightSwitch = Nothing WScript.Quit </script> </job> </package>
You can call this .wsf file directly from a command prompt:
C:\PersistentVariables> Toggle
You have to make sure, that the PersistenVariables.vbs file is in the same folder as the Toggle.wsf file.
Please find a complete explanation of the usage of persistent variables outside of call routing scripts here:
By Tom Wellige