Guy’s Scripting Ezine 117 – Troubleshooting VBScripts

Guy’s Scripting Ezine 117 – Troubleshooting VBScripts

 ♣

This Week’s Secret

This Week’s Mission is to pass on my ‘soft’ troubleshooting secrets.  Here follows a list of seven unusual, even zany tips, these are strategies that you are unlikely to find in a textbook, but they offer an insight into my approach to problem solving.  You could regard these strategies as inspiration for that moment when, after researching the error code number you still cannot find the answer.

Now I realize that this list is not exhaustive, and my greatest joy would be if you would write in with your pet troubleshooting method.

Seven Troubleshooting Strategies

1) Golden Rule – Break your script into sections

2) Play the numbers game

3) Try a Walk-Through

4) If you are still stuck try a parallel approach

5) Change of Scenery

6)Avoid ‘Over-think’

7) Find a Sounding Board

1) Golden Rule – Break your script into sections

When I get a request for assistance with a VBScript, I often reply with the sentence: ‘Breakdown your script into its simplest components, get each command working in isolation, only then bolt the sections back together’.  In my own scripts you may see traces of troubleshooting sections in the form of extra WSCript.echo messages.   Sometimes I forget to remove them after testing the  script, on other occasions I deliberately leave the WSCript.echo statement, just to alert you that VBScript has performed an action.

The reason this strategy works is because you simultaneously build on success while narrowing down the search area for the fault.

2) Play the numbers game.

Start solving VBScript errors by playing the numbers game.

Rule 1) Trace the line numbers of the error.
Rule 2) Check the hex numbers (Here is my section on error code numbers)
Rule 3) Get the phone number of a friend, or even the phone number of Microsoft Support.Troubleshooting advice for VBScript.  Problem solving ideas.

While you play the numbers game, pretend you are Sherlock Holmes searching for clues.  Look for patterns.  Take these two error messages 800708CA and 800A01F4; with just a glance at 800708CA I can tell this is an operating system problem, the clue is that ‘7’ in position 4.  Notice how in the second hex number, 800708CA, we have an ‘A’ in position 4, thus indicating a syntax error. 

Further research indicates 800708CA means network connection does not exist, whereas 0800A01F4 means variable undefined.  Incidentally, the underlying problem was trying to remove a network drive that did not exist.

Get a good script editor.  When you are troubleshooting, you need every advantage that you can get, thus a script editor will help by displaying the line numbers.  The advantage is that when get a WSH error message you won’t have to count down to line 81 or where ever the message directs you. 

The better script editors also color code the commands, as a result you can often see a sudden change to red letters where you make a typo.  As a bonus good script editors give you a context sensitive library of commands, which extends your scripting vocabulary.  These days,my choice of script editor is OnScript.

3) Try a Walk-Through

It is amazing how often a manual walk-though of the task sheds extra light on a scripting problem.  In particular, watch out for steps that are missing in the script.  For example, pressing the OK button in a dialog box requires the VBScript command: obj.SetInfo.  Following this theme, as you step through the task manually, observe how the default radio buttons are set.

Another advantage of a walk-through is that may reveal that what you want to achieve cannot be done with a VBScript.  Trust me, I have a whole folder full of readers’ plans for mission impossible.   Many plans sound plausible until you try a walk-through.  For example, I had a request to add a photograph to each user’s property sheet.  Could I kindly help with a script.  It seemed a nice idea until a walk-through in Active Directory Users and Computers exposed that there is no way of adding a user’s photograph.  It also struck me that even if the script could magically achieve the mission, then how would you see the photo?

4) If you are still stuck try a parallel approach

4a) Suppose that your mission is to map a network drive, but the script just won’t work.  Instead of going around in circles, try mapping a printer.  If that also fails, look for a common cause, for instance, the fault maybe because you are created an environmental object instead of a network object.  By trying a parallel approach you can isolate the error.

4b) Here is another example, you are trying write to a file; but it fails, why not try to read from a file instead?  This will prompt you to re-examine the Const statement and also to check that folder\file referenced in the script, is where you think it is.

4c) Cannot run Excel?  Try to run Notepad instead, if that works it could mean that Excel is not installed.

4d) Seek similar examples on the internet.  Leave a request in your favourite forum.

My hidden message with this approach is when the parallel command works, you are at the start of a winning roll of the VBScript dice.  What I find is that when I get even a small success, then my confidence grows and what was a difficult problem, suddenly becomes a cinch.  Don’t underestimate the power of positive thinking.

5) Change of Scenery

Perhaps what you need to solve the problem is sharper focus, or greater attention to detail.  In this case, break out of that terrible loop where you go around in circles.  Print out your script, but take it to another room where you read each line carefully.  Don’t ask me why, but it works for me.  A psychologist may say that I associate the dinning room with concentrating on fine detail.

I repeat that when it comes to troubleshooting getting into a positive frame of mind is as important as technical know-how.  Thinking positively opens up the mind to alternative avenues, for example, leave a question in a forum, or email-a-friend.  To fix a script that’s not working, you need to develop the ‘can do’, or ‘I can walk on water mentality’.  Let me play devils advocate for a minute, if you are in a bad mood, then common sense dictates that this negative attitude will sap your problem solving abilities.

Blame someone.  I don’t like this idea at all.  However, my friend ‘Mad’ Mick swears that sticking pins in cabbage patch doll labelled Bill Gates, fires up his brain and solves the problem.  Physical out bursts do not work for me, but if punching the door, or kicking the wall makes you feel better and gets you into problem solving state, then who am I to judge.  Incidentally, this indicates I am willing to publish tips even if they don’t work for me.

Guy Recommends: Tools4ever’s UMRAUMRA The User Management Resource Administrator

Tired of writing scripts? The User Management Resource Administrator solution by Tools4ever offers an alternative to time-consuming manual processes.

It features 100% auto provisioning, Helpdesk Delegation, Connectors to more than 130 systems/applications, Workflow Management, Self Service and many other benefits. Click on the link for more information onUMRA.

6)Avoid ‘Over-think’

‘Over-think’ can be a bit like amateur bird watchers.  When out ‘twitching’ they always claim to have seen a rare exotic finch, when what they are really looking at is a Great Tit.  In the case of amateur script writers they claim it’s a rare VBScript error, when actually they have left a bracket unclosed.  My message is start by looking for the simplest, most likely cause of the errors, checking for typos would be a good place to begin.  Naturally a good script editor helps to identify such errors either by color coding or through pin-pointing the line with the fault.

7) Find a Sounding Board

It never ceases to amaze me how many people solve their own problem simply by writing down what has gone wrong and what they want their script to achieve.  How do I know this?  Because lots of people write to me for help with their scripts.  When I reply, I would estimate that 30% of people say in the meanwhile (a few hours) they have solved their problem.  I am able to assist a further 30% by giving them a fresh insight, or by nudging them in the right direction.  All that I have done is act as a sounding board and magically they see how to correct the error.

In conclusion, if only more people would simply write down the problem and reflect on the desired result, then their brain will conjure a solution.  For some people and certain types of problem, drawing diagrams helps clarify what’s happening and thus points to the way out of the scripting maze.  Drawing a ‘Pipe’ between the user object and Active Directory would be a case in point.

Readers Suggestions

The Custard Rule

"When everything turns to custard go back to your original assumptions and recheck them"

Lets face it, when fault finding you have to make assumptions about what might be wrong otherwise progress will never be made. The problem, and it is mostly a human one, is that you start to imagine solutions based the original assumptions which in themselves are based on no real hard evidence.  Laurie Sparke

Guy Recommends: SolarWinds Free Network Bandwidth MonitorFree Real-Time Bandwidth Monitor

This freeware monitor is great for checking whether your network’s load-balancing is performing as expected, for example, are two interfaces are getting about equal traffic?

It’s easy to install and straightforward to configure. You will soon be running tests to see how much network bandwidth your applications consume.

The GUI has a lovely balance between immediate network traffic data in the middle, combined with buttons to seek related data and configuration settings. Give this monitor a try, it’s free! 

Download your free network bandwidth monitor

If you need more comprehensive network analysis software:
Download a free trial of NPM (Network Performance Monitor)

Read the Screen!

Miguel reminds us: So often the answer to the problem is there staring on the screen staring at us, so read the message, carefully.  Especially with Windows Script Host dialog boxes, they are full of useful information.  Miguel Lopez.

Record what you do.

How many times has your solution made the problem worse?  How often have you wished you could backtrack and start all over again.  This is why you should always write down the steps you take, in the long run it will save you time.  Christoffer Johannson

Guy Recommends: Tools4ever’s UMRAUMRA The User Management Resource Administrator

Tired of writing scripts? The User Management Resource Administrator solution by Tools4ever offers an alternative to time-consuming manual processes.

It features 100% auto provisioning, Helpdesk Delegation, Connectors to more than 130 systems/applications, Workflow Management, Self Service and many other benefits. Click on the link for more information onUMRA.

Guy’s Advice and After Sales Service

Perhaps it would be best if I start with my dream solution for Guy’s after sales service.  If there is a mistake in my script, or an instruction is unclear, then the onus is on me to fix the problem and answer such email for free.  If relevant, I would offer a free ebook, or in an ideal world, make a small PayPal payment to the customer to compensate for my mistake.

Where the script does not do what the reader wanted, or they cannot get it to work, if it’s easy then I would help them for free.  For example, their script fails because they overlooked my instruction: ‘Change objOU to an Organizational Unit in your Active Directory’.  The customer emails me THEIR script as a text file, I point out the error e.g. change the value for objOU, job done for free.

For situations where a customer buys my Logon Script Ebook, but then wants a script that maps 10 different drives to 15 different shares, which is dependant on a hierarchy of 7 different group memberships, then I would charge for creating a bespoke script.

Beyond After Sales

Now I am convinced that there is a business opportunity for someone to provide a paid service to create and troubleshoot scripts.  Unfortunately, at the moment, that person is not me.  My problem is that I cannot get an effective pricing model to work, consequently, I am not, repeat not, actively looking for work writing or correcting VBScripts.

Returning to the famous ideal world, readers would make micro-payments for my services.  Now, you and I hate ‘make-work’, thus the hassle for customers to make a $5 payment is greater than value of the service.  The result in many cases is an uneasy standoff, the customer won’t pay $25 and I am reluctant to keep answering questions that are not directly to do with my scripts, for free.

To conclude, here is a statement of my present position. 

1) I will continue providing an after sales service for my site in general and my ebooks in particular
2) I am happy to act as your sounding board for a quick evaluation of your problem
3) I am not actively looking for paid work in creating bespoke VBScripts.  Instead, I believe that the best use of my time is writing articles for my website and this ezine.

See more about VBScript error correcting codes

VBScripts  • 800 Code list  • Ezines  • Logon Scripts   • PowerShell ErrorAction  • VM Monitor

Ezine 72 Error correcting  • Ezine 107 Error correcting  • Tool Kit   • WMI Monitor Review

Ezine 96 Errors  • Ezine 117 Troubleshooting pure  • Ezine 130 VBScript codes