You may receive an "Object not a collection" error message when you try to use the stdregprov class in WMI to read values in the HKEY_CURRENT_USER (HKCU) registry hive in Windows Server 2003 (888318)



The information in this article applies to:

  • Microsoft Windows Server 2003, Standard Edition
  • Microsoft Windows Server 2003, Enterprise Edition
  • Microsoft Windows Server 2003, Datacenter Edition

SYMPTOMS

When you try to use the stdregprov class in Windows Management Instrumentation (WMI) to read values in the HKEY_CURRENT_USER (HKCU) registry hive, you may receive the following error message:
Object not a collection
If you receive a return code from the EnumKey method, the return code is return code 5. Return code 5 means that access is denied.

Additionally, the following event message may be logged in the Application event log in Event Viewer:
Source: Userenv
Type: Warning
Event ID: 1517
Description: Windows saved user Domainname\username registry while an application or service was still using the registry during log off. The memory used by the user's registry has not been freed. The registry will be unloaded when it is no longer in use.

This is often caused by services running as a user account. Try configuring the services to run in either the LocalService or NetworkService account.

For more information, see Help and Support Center at http://support.microsoft.com.

This problem may occur in Microsoft Windows Server 2003.

CAUSE

This problem may occur because the profile of the user is loaded when the stdregprov class tries to read values in the HKCU registry hive. However, the stdregprov class never unloads the profile of the user after that. Therefore, if you use another account to log on to the computer, and then you try to read a value in the HKCU registry hive, you may receive return code 5. You may receive return code 5 because WMI is still using the previous profile.

STATUS

Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section.

MORE INFORMATION

Steps to reproduce the problem

  1. Log on to a Windows Server 2003 based-computer as an administrator.
  2. Run the following Microsoft Visual Basic test script code on the computer.
    Const HKEY_CURRENT_USER = &H80000001
    strComputer = "."
    Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")
    strKeyPath = "SOFTWARE\Microsoft"
    retval = oReg.EnumKey(HKEY_CURRENT_USER, strKeyPath, arrSubKeys)
    WScript.Echo retval
    oReg.EnumKey HKEY_CURRENT_USER, strKeyPath, arrSubKeys
    For Each subkey In arrSubKeys
          Wscript.Echo subkey
    Next
    Set oReg = Nothing
    
  3. Log off as an administrator. Log on as another user who is not an administrator. Try to run the same Visual Basic test script code.

    You may receive the error message that is mentioned in the "Symptoms" section.

Modification Type:MajorLast Reviewed:9/22/2006
Keywords:kbQFE kbprb KB888318 kbAudDeveloper