Computer Performance, Logon Scripts

Guy recommends :
Free Solarwinds
VM Console

Solarwinds VM Console Free Download

Find out which of your VMs are a waste of space and which VMs need more resources.


Guy's Review of
Computer Utilities

 1) FreePing
 2) Engineer's Toolset
 3) Xobni
 4) PuTTY
 5) WMI Monitor
 6) BgInfo
 7) Net-SNMP
 8) IP Address Tracker
 9) DNS Stuff
10) WinDiff Compare


Code Error 800A0400 - Expected Statement

Troubleshooting Code 800A0400 - Expected Statement

Perhaps instead of 'Expected Statement', 'missing character' would be a better error message.  I have noticed with error 800A0400 how often the problem is at the beginning or the end of the line mentioned in the error message.

Introduction to Code 800A0400

Error code 800A0400 is a generic message when you execute a VBScript.  A wild guess, you have missed a command at the beginning of a line.Code 800A0400 Expected Statement VBscript error

The Symptoms You Get

The script does not execute as you had hoped.  Instead you get a message box like this picture:

The Cause of Error 800A0400

Your VBScript contain is missing a statement.  This is a difficult error to track down.  However, the good news is that I have three examples.  Most likely you have placed a statement, which is not appropriate for the logic of your script.  For example, extra brackets, or missing command. 

Note: the clue 'Source: Microsoft VBScript compilation error'.  My point is that 'compilation error' and not a 'runtime error', means this is a syntax error in your script.

The Solution for Error: Expected statement

The Windows Scripting Host gives us two useful clues, firstly, look on Line: 10, do count any remark or empty lines.  Secondly, the Char: number 1, is useful in tracing the error.  In this case there is something wrong with the Select statement.

The line number, as is so often the case, is crucial to solving this error.  The problem is that the whole line is gibberish to the VBScript engine.  So take another look at each word, punctuation and see if you can spot a simple error.

  ‡

Example 1 of Error code: 800A0400

Missing underscore at the end of the line 7:

' WSHname.vbs
' Sample VBScript to check WSH Version
' Author Guy Thomas http://computerperformance.co.uk/
' Version 2.3 - September 2010
' -------------------------------------------------------
On Error Resume Next
WScript.Echo "WSH Version: " & WScript.Version & " " & WScript.BuildVersion
& vbcr & "File name: " WScript.ScriptName
WScript.Quit

Solution

Missing underscore at the end of the line:

WScript.Echo "WSH Version: " & WScript.Version & " " & _

' WSHname.vbs
' Sample VBScript to check WSH Version
' Author Guy Thomas http://computerperformance.co.uk/
' Version 2.3 - September 2010
' -------------------------------------------------------
On Error Resume Next
WScript.Echo "WSH Version: " & WScript.Version & " " & _ WScript.BuildVersion
& vbcr & "File name: " WScript.ScriptName
WScript.Quit

Guy Recommends: SolarWinds Engineer's Toolset v10Engineer's Toolset v10

This Engineer's Toolset v10 provides a comprehensive console of utilities for troubleshooting computer problems.  Guy says it helps me monitor what's occurring on the network, and each tool teaches me more about how the underlying system operates.

There are so many good gadgets; it's like having free rein of a sweetshop. Thankfully the utilities are displayed logically: monitoring, discovery, diagnostic, and Cisco tools.  Download your fully functional trial copy of the Engineer's Toolset v10

Example 2 of 800A0400

Error on Line 4.

Talk about stupid errors, there is no ' apostrophe to Rem out that line of dashes.

Actual

------------------------

Should be:

 '   -----------------------------

'The script is below, and the pclist.txt contain only 2 line:
' mainsrv
' computer1
--------------------------------------------------------
Const ForReading = 1
Set objDictionary = CreateObject("Scripting.Dictionary")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile _
("e:\scripts\pclist.txt", ForReading)
i = 0
Do Until objTextFile.AtEndOfStream
strNextLine = objTextFile.Readline
objDictionary.Add i, strNextLine
i = i + 1
Loop
For Each objItem in objDictionary
StrComputer = objDictionary.Item(objItem)
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer& "\root\cimv2")
Set colServices = objWMIService.ExecQuery _
("SELECT * FROM Win32_Service")
Wscript.Echo strComputer, colServices.Count
Next

Example 3 of 800A0400  (Code available)

I just plain missed command, for example no 'Set'.

Problem

"Error" ObjNetwork = CreateObject("Wscript.Network")

Correction

Set ObjNetwork = CreateObject("Wscript.Network")

Example 4 - No need for End If

The 800A0400 error message in VBScript often appears when the user adds a "End" statement when there is no need for one. For example, in this script, the user puts "End If", when there is no If statement to end.

MsgBox "Click OK to continue"
Input = InputBox("Type your name")
End If

There was no need for the user to put "End If", so the script host says that the user needs to put an 'If' statement, but wouldn't it make much more sense if it told the user to delete the 'End If' statement?

This example was kindly sent in by Alex Jones.

Guy Recommends: WMI Monitor and It's Free!Solarwinds WMI Monitor

Windows Management Instrumentation (WMI) is one of the hidden treasures of Microsoft operating systems.  Fortunately, Solarwinds have created the WMI Monitor so that you can examine these gems of performance information for free.  Take the guess work out of which WMI counters to use for applications like Microsoft Active Directory, SQL or Exchange Server.

Download your free copy of WMI Monitor


Do you need extra help?

For interpreting the WSH messages check Diagnose 800 errors.

For general advice try my 7 Troubleshooting techniques

Give something back?

Would you like to help others?  If you have a good example of this error, then please email me, I will publish it with a credit to you:

If you like this page then please share it with your friends

 


 *


Custom Search

Solarwinds Network Device MonitorSolarwinds' Free Network Device Monitor

Thus utility makes it easy to check the health of a router or firewall.  Check the real-time performance and availability statistics for any device on your network.

Get started with an extensive collection of "out-of-the-box" monitors for popular network devices.  Download your free Network Device Monitor

 

Home Copyright © 1999-2012 Computer Performance LTD All rights reserved

Please report a broken link, or an error.