Microsoft KB Archive/888318

= You may receive an &quot;Object not a collection&quot; 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 =

Article ID: 888318

Article Last Modified on 9/22/2006

-

APPLIES TO


 * Microsoft Windows Server 2003, Standard Edition (32-bit x86)
 * Microsoft Windows Server 2003, Enterprise Edition (32-bit x86)
 * Microsoft Windows Server 2003, Datacenter Edition (32-bit x86)

-





SYMPTOMS
When you try to use the stdregprov class in Windows Management Instrumentation (WMI) to read values in the  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  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  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  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 &quot;Applies to&quot; section.



Steps to reproduce the problem
 Log on to a Windows Server 2003 based-computer as an administrator.  Run the following Microsoft Visual Basic test script code on the computer. Const HKEY_CURRENT_USER = &H80000001 strComputer = &quot;.&quot; Set oReg=GetObject(&quot;winmgmts:{impersonationLevel=impersonate}!\\&quot; & strComputer & &quot;\root\default:StdRegProv&quot;) strKeyPath = &quot;SOFTWARE\Microsoft&quot; 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  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 &quot;Symptoms&quot; section.

Keywords: kbqfe kbprb KB888318

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.