Applies To:
  • CitectSCADA
  • CitectHMI

Summary:

VBScript is a very usefull tool for use with CitectSCADA for performing operations that are not natively available to Citect, or may be much more complicated otherwise.

VBScript files (*.vbs) are able to be executed directly in windows via the WSH (windows script host) ie you can just doubleclick on any file ending in *.vbs and it will automatically run. You can also just type the scripts filename at the command prompt and it will run.

However running VBScripts from Citect is not as simple as referencing the *.vbs file directly in the Cicode Exec(). As the vbs is not a directly executable program.

 

Solution:

The WSH has a GUI mode (wscript) and a command line mode (cscript).

You need to call the Cscript program and tell it which script to run. Eg  Exec("cscript c:\myscripts\xyz.vbs")

For more complex operations where you wanted to collect some of the output from the script for use in Citect. You can direct the output to a text file then open that text file in Citect to read the contents.

Eg Exec("cscript c:\myscripts\xyz.vbs > c:\myscripts\output_from_script.txt")

You can get further details on the options (such as suppressing errors) by typing "cscript" at the windows command line.

More general information on windows scripting is available here: http://en.wikipedia.org/wiki/Windows_Script_Host

 

Keywords:
 

Attachments