Computer Performance, Logon Scripts

Code Error 800A0401 - Expected end of statement

Troubleshooting Code 800A0401 - Expected end of statement

Good news, here is another example of a WSH error message with a helpful Char: number.  Count along the line until you get to the offending character.  With Error 800A0401 start by looking for missing ampersands (&).

Introduction to Code 800A0401

Error code, 800A0401 occurs when you execute a VBScript.  This is a compilation error, therefore check your punctuation.  A wild guess, you have left out an ampersand (&), or possibly a comma.Code 800A0401 - Expected end of statement

The Symptoms you get

The script does not execute as you had hoped. Instead, Windows Scripting host generates a message box like this picture:  Good news, I have three examples of code: 800A0401.

The Cause of Code 800A0401

Your VBScript contains a punctuation error.   Note: The clue from Source: Microsoft VBScript compilation error, this means a syntax error in your script.  In this case the Char: number (33) is particularly valuable in troubleshooting.

The Solution to Error: Expected end of statement

Check the syntax of your script, in particular double-check punctuation marks (&, comma, speech marks or full stop.).  In this instance, Windows Scripting Host has detected a mix-up between a comma and a full stop.  As ever, a line number is helpful when troubleshooting, moreover, any Char : number other than 1, will pin-point the problem.

  ‡

Example 1 of Script for Code 800A0401

Note: The error is at Line 3, Character 33 - wbemServices, Instances

It should be wbemServices.Instances  (Full stop, and not a comma)
 

strComputer = "Alan"
set wbemservices = GetObject("Winmgmts:\\" & strComputer)
set wbemObjectSet = wbemServices, InstancesOf ("win32_LogicalMemoryConfiguration")
For each wbemobject in wbemobjectset
WScript.echo "Tot Physical Memory " & wbemobject.totalPhysicalMemory
Next
 

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

The 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 the tools teach me more about how the system itself 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 copy of the Engineer's Toolset v 10

Example 2 of Script for Error 800A0401

Problem

Wscript.Echo objNetwork.UserName " at " & objNetwork.ComputerName

An & (ampersand) is missing it should be:

Correction

Wscript.Echo objNetwork.UserName & " at " & objNetwork.ComputerName
 

 

Set ObjNetwork = CreateObject("Wscript.Network")
Wscript.Echo objNetwork.UserName " at " & objNetwork.ComputerName
 

Example 3 - Missing comma

The error is on line 10 char 33, it needs a comma between the drive letter and the UNC path

objNetwork.MapNetworkDrive "R:" "\\alan\backup"
objNetwork.MapNetworkDrive "R:" ,  "\\alan\backup"

 

' BudgetPear.vbs
' Script to map the Budget share on the server pear
' Version 1.1 August 2004
' Guy Thomas http://computerperformance.co.uk

Option Explicit
Dim objNetwork

Set objNetwork = CreateObject("Wscript.Network")
objNetwork.MapNetworkDrive "R:" "\\alan\backup"
WSript.echo " Share Mapped "
WScript.Quit

' End of Guy's script
 

 

Summary of Error Code 800A0401

As usual with 0800 error codes, check the line number and the char number.  Pay careful attention to any punctuation.  Is there a comma, missing?  Could there be a comma, where the script needs a full stop?

Solarwinds IpMonitorTry 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 (21 day eval).

Computer Training Software - Recommended Training VideosGuy Thomas recommends Computer Training Software

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.


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:

 

 *


Google

Web  This website

Review of Orion NPMGuy Recommends: Orion's Network Performance Monitor (NPM)

Orion NPM is designed for detecting network outages.

Network-centric views (screenshot) make it easy to see what's working, and what needs your attention.

Download your free trial of Orion's network performance monitor

 

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

Please report a broken link, or an error.