Hints to help you troubleshoot your programs and scripts

In VBScript programs, use an "Option Explicit" statement. This makes it much easier to find errors. With this statement, every variable must be declared (usually with a "Dim" statement). Any variable that is not declared raises an error, which makes misspellings immediately apparent.

Don't use "On Error Resume Next" in VBScript, unless you anticipate specific errors and handle them. Although trapping errors is a useful feature, it can mask problems. You want to know which statement first raises an error.

If you are having a problem, try to isolate it. Reduce the code to the minimum needed to duplicate the problem. This is also useful when you post code in a forum seeking help to fix a problem.

Especially if a program is long, temporarily add output statements to indicate progress in your program. Output the values of variables to verify they are what you expect.

If the problem seems to be in a loop, it can help to add an output statement in the loop to reveal variable values on each iteration. Often, the loop executes as expected most of the time, but raises an error when a variable becomes out of range or has an unexpected value.

Test programs in a test environment, with test users and groups. Logon scripts especially should be tested under all expected conditions, on all client operating systems.

Many scripts that deal with Active Directory raise an error when an object is saved. In VBScript this when the "SetInfo" method of an object is invoked. This could be caused by any property values assigned since the last save. All changes are made in local memory until the changes are saved to Active Directory. That is when errors can be raised. Often a syntax or formatting error is the problem.

ADO search routines often raise an error when the query statement is executed (the Execute method is invoked). Any syntax error in the query statement could cause this.