WSHHelper - Class

Provided by Ernest Edwards
Extended by Guenter Born

Description

WSHHelper.dll provides a class to assist with debugging WSH scripts without using MsgBox calls within your script. Instead a Print method may be used to instrument a WSH script. The Print methods send the string to a debugger (like SysInternals' Debug Viewer www.sysinternals.com, which is highly recommended). The Enabled properties turns it on and off.

How to download the debugger and register the WSHHelper?

Well, here are the steps to obtain and register the necessary tools for debugging:

Registering the WSHHelper.dll may be done with the file Register.bat. After registering the dll once, the class will be accesseable from WSH scripts. Unregistering may be done using the file Unregister.bat.

How to use the tool?

Viewing the debug output is rather simple:

  1. Run the debugger viewer (from sysinternals).
  2. Run an instrumented WSH script.

The debugger viewer windows will display the debugging output send from the script.

How to instrument the WSH script?

Instrumenting means: add lines to your script that prints messages about script values or whatever else. First of all, you need to create an instance of WSHHelper using CreateObject method.

' for VBScript
Dim dbg
Set dbg = CreateObject("WSHHelper.DebugOutputString")
//for JScript
var dbg = WScript.CreateObject("WSHHelper.DebugOutputString");

After creating the object instance, you may use the Print method:

dbg.Print "this is a string"      ' VBScript
dbg.Print ("this is a string");   // JScript

Disabling debugger helper output may be done using the Enabled property:

dbg.Enabled = 0     ' disable output
dbg.Enabled = 1     ' enable output

The zip-archive contains a simple VBScript and a JScript sample demonstrating how to use the above methods and properties.

Copyright & Warranty

The WSHHelper.dll is copyrighted to Ernest Edwards. It comes AS-IS, without any warranty or support of any kind. Use at your own risk.

2004 - by G. Born