Is your server running slowly? Check with SolarWinds ipMonitor
Get a free evaluation copy of ipMonitor
Contents for Guy's Scripting Ezine 49 - Common Errors
Guy wants more errors! What I mean is, please email me with any
0800xxxxx error messages that you cannot solve. I am particularly
interested in new errors which I can add to my Error Codes section.
I will let you into a secret, dealing with these VBScript errors gives me a
fascinating insight into how people ask for help. In
a nutshell, everyone imagines that I know
all about their operating system. They even imagine that I am there watching what they are
doing when the error happens. Whereas in reality, I have no
idea whether their code 0800xxxxx message is caused by a VBScript on an XP machine, or
the .ASP
front-end of a SQL database.
I will let you into another secret, some of my best work is achieved by
merely getting
people to write down their problem, you may be amazed how often just the act
of describing the symptoms, triggers one's brain into working out the solution.
If only I could patent this 'sounding board' effect, then I could make a
fortune.
I will let you into one more secret, really more of a confession. Some of my error messages explanations
are ropey, whilst others need more examples. What I want to do is expand
each of my 800 error pages and give a wider range of scripts that caused the error.
So, this is why I am encouraging you to send in screen shots of your errors.
Problem solving is a knack. Just as some people have green fingers, others
can see solutions to problems in an instant. There are two vital qualities in a trouble-shooter. Firstly confidence, that belief that you will solve the problem. Secondly a rich variety of
tools and sources of information. Where the 'green fingers' comes in is the ability to change from one tool to another, to switch from examining the error code number to researching in TechNet. In
my own case, experience from the hard school of knocks also plays a large part in moulding my troubleshooting skills.
One secret of solving problems is asking the right questions. It's rather
like finding the treasure at the center of a maze. If each fork in the
path represents a question, then it is a matter of devising a question which only
has two possible answers, and each successive question halves the search area.
By making successful choices, you home-in on the solution.
The first clue to lookout for when you see an 0800 error is the line number. Only exceptional trouble-shooters pay attention to detail and read what the error actually says. While I admit that sometimes the error messages
are
incomprehensible, for example: 'One or more errors occurred during processing of command',
yet on a good day the message provides the obvious answer, - 'The Device is already
in Use'.
The first fork in your decision tree should establish if the fault is internal to the script, or an external
problem on the computer network. Decide whether the trouble lies with VBScript logic, for example a syntax error, or whether there is something wrong with network, for example the server is down, (or does
not exist).
To help you with this initial question study the 4th digit in the 800x0000
code. The 'tell' or 'give away', is whether the 4th character is an A or 7. For example, there are 53
syntax errors all beginning with 800Axxxx. Here are the most common 800A errors
(judged by page hits on my site's error code section).
Code 800A000D - Type Mismatch (In method). For example
MapSNetworkSDrive instead of MapNetworkDrive
Code 800A01B6 - Object does not support that property. Could be a
missing 'Set' command
Code 800A0401 - Expected end of statement. Most commonly a missing & (ampersand)
Code 800A01A8 - Object Required - Typo, or missing element.
On the other hand, if your error begins with 8007xxxx then look for an factor outside VBScript
itself. For instance, check the spelling of your share or
printer name. Another possibility is that the server referenced by the script is
unavailable.
Code 80070055 - Drive letter already in use
Code 80072030 - No such object
See more Code Errors here.
While the main theme of this week's Ezine is error codes, I am also going to
feature: If...EXISTS. Actually, there is a whole group of EXISTS methods,
and this week we
will employ the FOLDEREXISTS member of the family. To tell the truth, I should
have used this in Ezine 43 - FSO basics. As the name suggests, EXISTS checks for the
occurrence of an object. In this particular script, we need to know if there is
already a folder called C:\guy. If the answer is NO, then the script creates the
folder, if the answer is yes, it exists, then we avoid an error by not trying to
create yet another folder called c:\guy.
This script will be our 'vehicle' to test error codes.
Instructions
- Copy and paste the script below into notepad.
- Save the file with .vbs extension e.g. CreateFolder.vbs.
- Double click and examine the message boxes.
- Navigate to your C:\ drive and look for a new folder called C:\ Guy.
' Set CreateFolder.vbs
' Purpose of script to create a folder
' Author Guy Thomas http://computerperformance.co.uk/
' Version 1.2 - October 10th 2004
' -----------------------------------------------------------------'
Option Explicit
Dim objNetwork, objComputer
Dim objFSO, objFSOText, objFolder, objFile
Dim strDirectory, strFile, MakeObject
' Create the File System Object
strDirectory = "C:\Guy"
Set objFSO = CreateObject("Scripting.FileSystemObject")
' Test to see if the folder exists
If objFSO.FolderExists(strDirectory) Then
Wscript.Echo strDirectory & " already exists"
Else
Wscript.Echo "No " & strDirectory
Set objFolder = objFSO.CreateFolder(strDirectory)
Wscript.Echo "Just created " & strDirectory
End if
Wscript.Quit
' End of example VBScript
Learning Points
Note 1: This script uses the FolderExists method.
What it does is check
to see if there is already a folder corresponding to strDirectory. Pay
close attention to the brackets: FolderExists(strDirectory).
Note 2: I love the construction: If... Then.. Else. End IF.
This week I have a script full of code 0800xxxxx errors, and I challenge you
to find the three errors and then correct the script.
' Set CreateFolderBad.vbs
' Purpose of script to create a folder
' Author Guy Thomas http://computerperformance.co.uk/
' Version 1.3 - October 10th 2004
' -----------------------------------------------------------------'
Option Explicit
Dim objNetwork, objComputer
Dim objFSO, objFSOText, objFolder, objFile
Dim strDirectory, strFile, MakeObject
' Create the File System Object
strDirectory = "C:\Guy\sub"
Set objFSO = MakeObject("Scripting.FileSystemObject")
' Test to see if the folder exists
If objFSO.FolderSNoExists(strDirectory) Then
Wscript.Echo strDirectory & " already exists"
Else
Wscript.Echo "No folder called: " & strDirectory
Set objFolder = objFSO.CreateFolder(strDirectory)
Wscript.Echo "Just created "
strDirectory
End if
Wscript.Quit
' End of example VBScript
Learning Points
Answers: check with the first script, pay particular attention to the
line numbers.
Every script writer makes mistakes. Professionals use the 800xxxxx
error messages to track down the cause, while amateurs ignore the error code and
struggle to get their scripts executing. With practice, you will become
expert at interpreting the code messages and soon distinguish between syntax
errors which begin with 800Axxxx and logical network problems which have a 7 as
the 4th digit, for example 80070055 - the drive already exists.
See more Code Errors here.
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.
|