5.8.5. ActiveX Scripting

When ActiveX is enabled, the scripting engine will be based on Microsoft Windows Script Technologies, it has complete reference for JScript .. Note that these are back-end or server side scripting, so not all functions or methods are accessible for browser/client (mimic) side scripting. For instance, file system object handling only available for server side scripting.

Very often user may want to execute external program from within server script. Below is an excerpt from MSDN website that shows how to execute system calculator program. Paste this script into server script, trigger it with a tag, Calculator will be running when the value of this tag changes, either via user button click, setting or received from IO device. However the program will only run on server but not remote client.

var WshShell = new ActiveXObject("WScript.Shell");
var oExec = WshShell.Exec("calc");

while (oExec.Status == 0)

And command line oriented application can be done via DOS batch file like below:

var obj = new ActiveXObject("WScript.Shell");

User may also perform their own file operation, below is another sample for server side scripting that executes SQL statement manually and save the output as CSV, user may customize accordingly and associate with the desired timer so it will execute periodically.

//compose your sql for desired data
var sql = "select time_stamp, tag_name, nvalue from log";
//assign to a string
var csv = "time_stamp,tag_name,nvalue\n" + getSql(sql, {dbgroup: 'mdb',outfmt: 'csv'});

//File System Object operation
var fso, tf;
fso = new ActiveXObject("Scripting.FileSystemObject");
tf = fso.CreateTextFile("c:\\testfile.txt", true);

tf.Write ( csv);

debugString( "File is saved.");
[Note] Note

Avoid to turn on ActiveX support unncessary as it will consume more system resources.