Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

stdregprov enumkey problem

27 views
Skip to first unread message

Stephen

unread,
Dec 19, 2003, 4:48:29 PM12/19/03
to
I am having difficulty with enumerating the contents of
the HKEY_USERS key of the registry. When I run it against
a Windows XP Pro SP1 box, it works properly. However, a
Windows 2000 Pro SP4 box does not return the correct
information (It looks like it might be information from
the HKEY_CURRENT_USER?).
I suspect it's a problem with the provider, but don't
know for sure. If so, is anyone aware of a workaround?

TIA,
Stephen

Here's my code:

PCName = "."

Set objLocator = CreateObject
("WbemScripting.SWbemLocator")
Set objService = objLocator.ConnectServer
(PCName, "Root\DEFAULT")
If Err.Number <> 0 Then
MsgBox "An error occurred while connecting to
the remote workstation.", vbCritical, "Error!"
Err.Clear
Exit Sub
End If

Set objRegistry = objService.Get("StdRegProv")
sPath
= "Software\Microsoft\Windows\CurrentVersion\Run"

result = objRegistry.EnumKey(HKEY_USERS, "",
arrSubKeys)

If Err.Number = 0 Then
For Each strSubKey In arrSubKeys
If Right(strSubKey, 8) <> "_Classes" Then
' objRegistry.GetStringValue HKEY_USERS,
strSubKey & "\" & sPath, strValue
' MsgBox strSubKey & vbCrLf &
strValue 'String(Len(strSubKey), "-")
varTemp = strSubKey & "\" & sPath
GetNCheck HKEY_USERS, varTemp

End If
Next
Else
MsgBox "Error " & Err.Description
End If

Torgeir Bakken (MVP)

unread,
Dec 19, 2003, 6:59:53 PM12/19/03
to
Stephen wrote:

> I am having difficulty with enumerating the contents of
> the HKEY_USERS key of the registry. When I run it against
> a Windows XP Pro SP1 box, it works properly. However, a
> Windows 2000 Pro SP4 box does not return the correct
> information (It looks like it might be information from
> the HKEY_CURRENT_USER?).
> I suspect it's a problem with the provider, but don't
> know for sure. If so, is anyone aware of a workaround?

Hi

This is a bug introduced with Service Pack 4 for Win2k :(

Some workarounds that might work better:


A)

You can use the command line utility Reg.exe to do a registry query (local and
remote)

Reg.exe is in the Win2k Support Tools found on the Win2k CD,
\Support\Tools\Suptools.msi, or for the latest version of
Support Tools (should work on non-SP4 computers as well):
http://www.microsoft.com/windows2000/downloads/servicepacks/sp4/supporttools.asp

In WinXP, Reg.exe comes default installed with the OS.


B)

Regobj.dll from Microsoft.

http://msdn.microsoft.com/vbasic/downloads/addins/componets/default.aspx


You can use a wrapper (encapsulate_regobj.zip) from
http://cwashington.netreach.net to get it more "user friendly".

You can also find a couple of sample scripts there, fill in RegObj in the
quickFIND field.

For more examples on RegObj.dll, go to
http://groups.google.com/advanced_group_search

and fill in e.g. the following words in the "Find messages with all of the
words" field:

RegObj.Registry


--
torgeir
Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of the 1328 page
Scripting Guide: http://www.microsoft.com/technet/scriptcenter


0 new messages