locked
WMI issue with VB script. RRS feed

  • Question

  • My product installer uses VB custom actions to create and manage  SCM service.  Within those VB custom actions, I use  WMI classes like Win32_Service, Win32_DependentService to manage the service.  I use class "Win32_DependentService" present under namspace "\root\cimv2" to get a list of depenedent services. On most of the machines, installer is able to execute VB custom action successfully that uses class "Win32_DependentService". But on few machines, This custom action fails. The installer log shows following runtime error

    Error Number    : 451
    Error Description    : Object not a collection
    Source        : Microsoft VBScript runtime error
    Method Name    : Function
    Operation    : Executing query to get dependent service list


    The code snippet where the custom action fails is as below:-

    <snip>
    Set objWMIService = GetObject("winmgmts:" & _
                                    "{impersonationLevel=Impersonate}!\\" & strComputer & "\root\cimv2")
      If Err <> 0 Then
                              ReportError MethodName, "Creation of winmgmts object for handling Windows services"
                              Exit Function
      End If
      Set colServiceList = objWMIService.ExecQuery _
          ("Select * from Win32_Service where Name = 'abc'")
      If Err <> 0 Then
                              ReportError MethodName, "Executing query to get handle to Existing abc service "
                              Exit Function
      End If
      For Each objService in colServiceList
        Set dependentServiceList = objWMIService.ExecQuery("Associators of " _
                                                           & "{Win32_Service.Name='abc'} Where " _
                                                           & "AssocClass=Win32_DependentService " & "Role=Antecedent" )
         If Err <> 0 Then
                              ReportError MethodName, "Executing query to get dependent service list "
                               Exit Function
         End If


    <\snip>


    I doubt something wrong is there in class "Win32_DependentService".  The WMI log file wbemcore.log present at "C:\WINDOWS\system32\wbem\Logs" shows following error

    <snip>

    2008.536529656) : CALL CWbemNamespace::ExecQuery
       BSTR QueryFormat = WQL
       BSTR Query = Select __Path,  Antecedent, Dependent FROM Win32_PNPAllocatedResource
       IEnumWbemClassObject **pEnum = 0xCFFE8
    (Mon Jun 02 20:46:28 2008.536529671) : CALL CWbemNamespace::ExecQueryAsync
       BSTR QueryFormat = WQL
       BSTR Query = Select __Path,  Antecedent, Dependent FROM Win32_PNPAllocatedResource
       IWbemObjectSink* pHandler = 0x0
    (Mon Jun 02 20:46:28 2008.536529687) : Query Engine request: querying dyn provider with <select __Path, Antecedent, Dependent from Win32_PNPAllocatedResource>
    (Mon Jun 02 20:46:29 2008.536529703) : Query Engine actual: querying dyn provider with <select __RELPATH, __Path, Antecedent, Dependent from Win32_PNPAllocatedResource>
    (Mon Jun 02 20:46:29 2008.536529718) : CALL CWbemNamespace::GetObject
       BSTR ObjectPath = Win32_PNPAllocatedResource
       long lFlags = 0
       IWbemClassObject ** pObj = 0x151F938
    (Mon Jun 02 20:46:29 2008.536530375) : Error 80041002 occured executing request for CancelProvAsyncCall for sink 043DBC70
    (Mon Jun 02 20:46:29 2008.536530375) : CAsyncReq_CancelProvAsyncCall call failed
    (Mon Jun 02 20:46:29 2008.536530437) : CALL ConnectionLogin::NTLMLogin
       wszNetworkResource = root\cimv2
       pPreferredLocale = (null)
       lFlags = 0x0
    (Mon Jun 02 20:46:29 2008.536530453) : DCOM connection from NT AUTHORITY\SYSTEM at authentiction level Privacy, AuthnSvc = 10, AuthzSvc = 0, Capabilities = 0
    (Mon Jun 02 20:46:29 2008.536530453) : GetUserDefaultLCID failed, restorting to system verion(Mon Jun 02 20:46:29 2008.536530468) : CALL CWbemNamespace::ExecQuery
       BSTR QueryFormat = WQL
       BSTR Query = Select __Path,  DeviceID, Name, Description from Win32_PNPEntity
       IEnumWbemClassObject **pEnum = 0x68B6358
    (Mon Jun 02 20:46:29 2008.536530468) : CALL CWbemNamespace::ExecQueryAsync
       BSTR QueryFormat = WQL
       BSTR Query = Select __Path,  DeviceID, Name, Description from Win32_PNPEntity
       IWbemObjectSink* pHandler = 0x0
    (Mon Jun 02 20:46:29 2008.536530484) : Query Engine request: querying dyn provider with <select __Path, DeviceID, Name, Description from Win32_PNPEntity>
    (Mon Jun 02 20:46:29 2008.536530484) : Query Engine actual: querying dyn provider with <select __RELPATH, __Path, DeviceID, Name, Description from Win32_PnPEntity>


    <\snip>


    The most annoying thing is that the same custom action works  and provides a list of dependent services if that VB custom action is called in VB script manually on command line on same machine. But It fails If It is called through installer. 

    I have followed all WMI troubleshooting steps mentioned at "http://www.microsoft.com/technet/scriptcenter/topics/help/wmi.mspx"  but It does not solve my problem. One thing I have noticed that the machines on which this problem is seen, I use domain admin account to install product MSI. 
     
    Any help to solve this problem is much appreciated. Thanks in advance !!

    Thanks,
    Abhay.
    • Moved by Bruno Yu Thursday, June 12, 2008 7:04 AM VBScript question is Off-Topic in VB.NET forum.
    Friday, June 6, 2008 6:27 AM

Answers