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.
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 2005
' -------------------------------------------------------------------- On Error Resume Next WScript.Echo "WSH Version: " & WScript.Version & " " & WScript.BuildVersion & vbcr & "File name: "
WScript.ScriptName WScript.Quit
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'.
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.