Guy’s Scripting Ezine 49 – Common Errors

Contents for Guy’s Scripting Ezine 49 – Common Errors

 ♣

This Week’s Secret

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.

Guy Recommends: The Free IP Address Tracker (IPAT) IP Tracker

Calculating IP Address ranges is a black art, which many network managers solve by creating custom Excel spreadsheets.  IPAT cracks this problem of allocating IP addresses in networks in two ways:

For Mr Organized there is a nifty subnet calculator, you enter the network address and the subnet mask, then IPAT works out the usable addresses and their ranges. 

For Mr Lazy IPAT discovers and then displays the IP addresses of existing computers. Download the Free IP Address Tracker

Common types of error

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 800×0000 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.

Introducing the ‘Exists’ family

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.

Example of a VBScript to create a folder

This script will be our ‘vehicle’ to test error codes.

Instructions

  1. Copy and paste the script below into notepad.
  2. Save the file with .vbs extension e.g. CreateFolder.vbs.
  3. Double click and examine the message boxes.
  4. 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 https://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.

Guy Recommends:  A Free Trial of the Network Performance Monitor (NPM)Review of Orion NPM v11.5 v11.5

SolarWinds’ Orion performance monitor will help you discover what’s happening on your network.  This utility will also guide you through troubleshooting; the dashboard will indicate whether the root cause is a broken link, faulty equipment or resource overload.

What I like best is the way NPM suggests solutions to network problems.  Its also has the ability to monitor the health of individual VMware virtual machines.  If you are interested in troubleshooting, and creating network maps, then I recommend that you try NPM now.

Download a free trial of Solarwinds’ Network Performance Monitor

Guy’s Challenge – Can you correct this faulty script?

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 https://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.

Summary

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.

See more about VBScript error correcting codes

VBScripts  • 800 Code list  • Ezines  • Logon Scripts   • PowerShell ErrorAction   • Free Log Tool

Ezine 7 On Error Resume  •Ezine 15 Error Codes  • Ezine 33 Troubleshooting  • Free WMI Monitor

• Ezine 49 Errors  • Ezine 54 Error correcting  • Ezine 69 Option Explicit  • Ezine 71 On Error