×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Error 0x80041002

Error 0x80041002

Error 0x80041002

(OP)
Getting an Error: 0x80041002 Code: 80041002 Source: (null)
in scripts on some computers (not others).

here is a snippit

CODE

strPCName = "."

Dim objWMIService, Err, objProcess, strShell, objProgram, searchkey
Dim strDisplayName, strDisplayVersion, strUninstall, strUninstallf
Dim subkey, oReg, arrSubKeys, strKeyPath, NValueName, VValueName, UValueName, intTest, intTest2

    strKeyPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" 'The path in the Registry needed to search
    NValueName = "DisplayName"
    VValueName = "DisplayVersion"
    UValueName = "UninstallString"
    ' On Error Resume Next
    Set oReg = GetObject("winmgmts:{impersonationLevel=Impersonate}!\\" _
& strPCName & "\root\default:StdRegProv")
    oReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys
    For Each subkey In arrSubKeys
    searchkey = strKeyPath & "\" & subkey

The error is hitting on the "Set oReg = " line.  I've copied it directly from all kinds of VBScript sites, with and without the ") _" line breaks and it keeps getting this error.  So, it is NOT the syntax of the line (since it works on some computers) The OS is XP on computers it works on and ones it doesn't.

From one site : (http://www.computerperformance.co.uk/Logon/code/code_80041002.htm)

"The Cause of Code 80041002

Your VBScript contains a misspelled object name.  Code 80041002 is an unusual Error in that a number is returned rather than 'Syntax Error' or other message.
The Solutions

Check the class definitions in the WMI section of the your script, check for extra letters, plurals can be a particular problem, e.g. system or systemS.  Note: The Line: 4 Char: 1  In this case it Char: 1 is not to blame.  When none of the line can execute, the error gets charged to the first character."

Which is NOT the case from all research I've done. (no misspellings).
.
So, WHAT is happening?
:O

RE: Error 0x80041002

(OP)
also used :

CODE

Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &_
 strComputer & "\root\default:StdRegProv")
 

and other variations of the line.

RE: Error 0x80041002

Well, my guess is it doesn't like the computername defined as "."

So how about changing the first four lines to this:

CODE

option explicit
Dim objWMIService, Err, objProcess, strShell, objProgram, searchkey
Dim strDisplayName, strDisplayVersion, strUninstall, strUninstallf
Dim subkey, oReg, arrSubKeys, strKeyPath, NValueName, VValueName, UValueName, intTest, intTest2
Dim WshNetwork, strPCName

Set objNetwork = CreateObject("WScript.Network")
strPCName = objNetwork.ComputerName
option explicit can be annoying but it's annoying for a damn good reason as it'll help errors caused by mistypes of variable names (e.g. strSystems instead of strSystem)

JJ
Variables won't. Constants aren't

RE: Error 0x80041002

(OP)
The Script in question is supposed to run through the local registry and uninstall old versions of Java, but not IBM java.
Below is the Full Script.  "java" can be changed to look for pretty much anything, it just needs to have a MSIExec.exe uninstall based string to uninstall silently.  Which is why I exclude the IBM Java, which has it's own funky uninstall string.

CODE

Option Explicit

Const JobSleep = 92000                'Time to sleep between jobs, in milliseconds
Const HKEY_LOCAL_MACHINE = &H80000002
Dim objFSO, strFileEntry, strPCName
Dim ListFile, LogFile, strPCDN, strRem1, strRem2, strRem3, strRem4, strRem5, strRem6
Dim objWMIService, objProcess, strShell, objProgram, searchkey
Dim strDisplayName, strDisplayVersion, strUninstall, strUninstallf
Dim subkey, oReg, arrSubKeys, strKeyPath, NValueName, VValueName, UValueName, intTest, intTest2

' Change text inside quotes after strDisplayName to text to search displayname for
' Make sure the uninstall string will be a MSIExec.exe uninstall to make it silent.
' I've included something to make sure the /I is replaced with /X to do the uninstall with MSIExec.exe


    strPCName = "."

RegistryPull(strPCName)

wscript.quit

Function RegistryPull(strPCName)
    strKeyPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" 'The path in the Registry needed to search
    NValueName = "DisplayName"
    VValueName = "DisplayVersion"
    UValueName = "UninstallString"    
    ' On Error Resume Next
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &_
strPCName & "\root\default:StdRegProv")
    oReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys
    For Each subkey In arrSubKeys
    searchkey = strKeyPath & "\" & subkey
      oReg.GetStringValue HKEY_LOCAL_MACHINE, searchkey, NValueName, strDisplayName
      oReg.GetStringValue HKEY_LOCAL_MACHINE, searchkey, VValueName, strDisplayVersion
      oReg.GetExpandedStringValue HKEY_LOCAL_MACHINE, searchkey, UValueName, strUninstall
     intTest=InStr(strDisplayName,"Java")
           If intTest <> 0 and intTest <> "" Then
           intTest2=InStr(strDisplayName,"IBM")
               If intTest2 = 0 or intTest = "" Then
                If strDisplayVersion <> "1.6.0.30" and strDisplayVersion <> "6.0.30.5" Then
                strUninstallf = Replace(strUninstall,"/I","/X")
                wscript.echo strUninstallf
                'Block to execute Uninstall
                Set objWMIService=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strPCName & "\root\cimv2")
                Set objProcess = objWMIService.Get("Win32_Process")
                Set objProgram = objProcess.Methods_("Create").InParameters.SpawnInstance_
                objProgram.CommandLine = strUninstallf & " /qn"
                Set strShell = objWMIService.ExecMethod("Win32_Process","Create",objProgram)
                WScript.Sleep(JobSleep)
                End If
            End If
        End If
    Next

Set objWMIService = Nothing
End Function

RE: Error 0x80041002

Setting the computername to . is perfectly valid. . jsut means "loacl Machine". If you are getting the error when you try to get the standard reg provider I would look at potential WMI corruption. Search google for WMI diagnosis. There is a script that MS released that does a very detailed analysis of the health of your WMI repository.

"... isn't sanity really just a one trick pony anyway?!  I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick

RE: Error 0x80041002

(OP)
JPJeffery,
The computer name being "." is what all the refrence docs I've found do.  I did change the lines to your suggestion, but still got the same error.
Refrence :
http://www.activexperts.com/activmonitor/windowsmanagement/adminscripts/registry/#ReadExpStringVal.htm

A similar script that just looks for "CA Uni" instead of "Java" is working on remote computers.  I am trying to test the script on a couple PCs and getting this problem.
I'm wondering if WMI is disabled or ... I dunno... impersonation level?? (I am administrator) I've changed the line to

CODE

Set oReg=GetObject("winmgmts:\root\default:StdRegProv")
and

CODE

Set oReg=GetObject("winmgmts:\\.\root\default:StdRegProv")
and even put in the actual computer name....

CODE

Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strPCName & "\root\cimv2")
gets the same error... (with and without the "{impersonationLevel=impersonate}!" included.

RE: Error 0x80041002

(OP)
Wmidiag.vbs helped a LOT.... found problems!  

http://windowsxp.mvps.org/repairwmi.htm

helped repair the problems with :

CODE

rundll32 wbemupgd, UpgradeRepository
and got my script working. :D

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close