VBScript Error Codes – 8004 Series

Error Codes 8004 Series HomeError Codes 8004 Series

Errors beginning with 8004xxx point to a WMI (Windows Management Instrumentation) error in your VBScript.

Error Code 8004 Series – Mainly WMI

  ‡

Also

Example Error Code 80041021

Windows Script Host Message Error Code 80041021 WMI VBScript

The script does not manipulate the WMI object as you had hoped, instead you get a Windows Script Host error message like this picture:

Case 1

Your VBScript contains a misspelled object name.  Code 80041021 is an unusual Error in that a number is returned rather than ‘Syntax Error’ or other message.  In my example the fault was in a WMI script, the cause was a syntax error with Set objWMI = GetObject("winmgmts:"

Correct
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\cimv2")

Wrong
Set objWMIService = GetObject("winmgmts:" _
& strComputer & "\root\cimv2")

The Solution

I solved this 80041021 error message by paying close attention to the line number.  In addition, I compared the scripts to other WMI examples.  In one case it turned out to be a missing \\ in Set objWMI = GetObject("winmgmts:\\"…..  In another case it was a missing & "{impersonationLevel=impersonate}!\\" _

If you are stuck try a parallel troubleshooting approach

Suppose that your mission is to create a WMI script which interrogates Win32_ComputerSystem, but the script just won’t work.  Instead of going around in circles, try substituting a different Win32_Object.  If that also fails, look for a common cause, for instance, the fault with:

GetObject("winmgmts:" & "{impersonationLevel=impersonate}!  By trying a parallel approach you can isolate the error.  See more general troubleshooting ideas

Also for more help with WMI Script, visit this section.

Solarwinds Free WMI MonitorGuy Recommends: WMI Monitor and It’s Free!

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 additional help?

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