This section concentrates on VBScript errors found in Logon and WMI
scripts. However, many of the principles also apply to .ASP,
COM and ActiveX errors.
Syntax errors. The WSH scripting engine parses the lines of your code,
if it finds unfamiliar expressions, it halts with an error message.
Syntax errors are caused by the usual suspects, mistyping keywords, forgetting to close brackets
or speech marks. These syntax errors always have an 'A' as the 4th digit, for example, 800Axxxx.
Runtime errors. Objects or components that your script requires may not be
available, for example, printers or network shares. Other causes of runtime errors, such as trying to divide
by zero are less common in the WSH context. The characteristic of these
external errors is a '7' in the 4th digit, for example, 8007xxxx.
Put on your detective hat and look for clues in the error message.
As with police investigators, it is collecting information and paying attention to detail, that is the key to solving the VBScript crime.
In addition to the Code: (80040E37) there are 4 other key lines to examine in your WSH error message.
Line: (20)
The line number and to a lesser extent, the char number, give you valuable information on where
to start your search for the cause of the error. When referencing the line number, count every line including
blank lines and ' Comments. Best of all, use a good script editor such as OnScript.
Char: (1)
I find the Char: number less useful than the line number. This is for the simple reason the value for Char is usually one, even though it's often not the first word that
is at fault.
However, if Char is a number other than (1) then this gives you a big clue. One area where you get meaningful Char: 58 numbers is with Syntax Errors.
Error: (Table does not exist)
As well as the Code 800... number, look for keywords in the
Error: which indicate what has gone wrong with your VBScript. For example, is the error indicating an object, network or printer, or as above, 'Table does not exit'
Source: (Provider)
The Source: Will often tell you
which method is faulty, for example MapNetworkDrive. In other example, the
error message
may tell you whether looking for a Compilation error or Runtime error. Compilation errors are common in the 800A series where they indicate faulty syntax.
The art of diagnosing 800 errors is knowing which of these four categories is the most important for your particular WSH Message box: Line: Char:
Error: Source:
Line: Is always important - full stop. Remember that you should count both bland and 'Remark lines.
Char: Is only important if it's a number other than 1. Often
800Axxxx series has a useful number such as, Char:53.
Error: More often than not, the Error message is laden with clues. Read carefully, then read again paying attention to each and every word.
Study phrases such as Error: 'Variable is undefined'. The only series
where error is not much help is the 8004xxxx.
Source: At its best when it names a method in your script. With the 8007xxxx series, Source: often throws up the name of the offending
method, for example MapNetworkDrive. In addition to a named method, the 800Axxx series may indicate Source: Microsoft VBScript compilation error, this means a problem with your syntax. On the other hand, the 8004xxxx series often reports (Null), which is not much help.
The first branch of your decision tree is syntax or logic. Does the error message
point to a syntax error? Alternatively, is there a mistake in the script or
network logic which triggers the error? Double
check that the name of the
share, server, computer or domain actually exists. Net View from the command
line will test that the machine is visible. To help you decide syntax or logic examine the fourth character, letter 'A' indicates a syntax problem, for example: 800Axxxx. Moreover, even a
glance at the Error: line will confirm that a bracket is missing or whatever the syntax fault is in this instance.
On error resume next
If, on the other hand, the error is logical, or a so called 'runtime errors' then the fourth digit is likely to be a '7'. Good news, you may be able to provide a temporary cure by adding: On error
resume next. However this should not be a permanent solution as it could push the problem underground.
Option Explicit
To generate more clues you could add Option Explicit. This
forces you to declare all your variables. My idea is that if you then
get a new error it could be a spelling mistake in one of your variables.
Error Handling Routines
Creating error handling routines is a specialist and time consuming task. All
production script should contain code to handle predictable problems such as the server with network share being unavailable. Even if you want a quick fix to your script, error handling routines can
provide extra clues. What makes error handling code difficult is that you need so many skills; in addition to VBScript, you need to master the logic of 'If ... then ... else End If' statements.
Errors beginning with 80005xxx mean an ADSI error. The situation is
that you are using the LDAP properties of an object, such as a user and there
is a mistake in the name of the attribute. For example, you script 'Surname' when you should call it 'SN'.
Another common mistake is thinking that DC=Yourdomain means domain controller, whereas it means domain context. What this means is use your fully qualified domain name and not the name of your domain
controller.
Code 8007xxxx - Operating System error e.g. Windows 2003
/ XP
The 8007xxxx family of errors point to a factor outside your VBScript.
Pay close attention to what the the Error: line is telling you. For example, Error: The network name cannot be found. If necessary, test the name of
your share or printer with a 'Net View' command.
Code 800Axxxx Syntax errors
There are 53 syntax errors all beginning with 800Axxxx. Carefully check the Error : line for more information on the punctuation error in your VBScript. In most cases these 800A syntax errors
are the easiest to solve because they give meaningful messages, even the Char: number is useful.
Try
a different solution, download SolarWinds ipMonitor
Here is my thinking,
ipMonitor will give you valuable data about your network and servers.
This extra information just may unlock the solution to your error code.
One more thing, sometimes when troubleshooting you go around in circles;
therefore if you try a different, but related approach, you may just crack the
problem.
Free Download
of SolarWinds ipMonitor
Their topics and material are ideal for getting you started with VBScript. The
videos are easy to follow and you can control the pace. Try their free demo material and then see if you want to buy the full package.
See more about VB Script Training CD.