Retrieving Registry Keys with VBScript

As part of a larger script, I 'm trying to use vbscript to query the registry for the keys contained in HKEY_USERS.  Here is the relevent part of the script:

strComputer = "."
Set objRegistry = GetObject("winmgmts://" & strComputer & "/root/default:StdRegProv")
Const HKEY_USERS = &H80000003
lngRtn = objRegistry.EnumKey(HKEY_USERS, "", arrRegKeys)
For Each strKey In arrRegKeys
Wscript.Echo "Key is " & strKey
Next

On my Windows XP PC, it works fine, and gives the following results for strKey:
.DEFAULT     (HKEY_USERS\.DEFAULT)
S-1-5-19     (HKEY_USERS\S-1-5-19)
S-1-5-19_Classes     (HKEY_USERS\S-1-5-19_Classes)
and so on

Hwoever on my Windows 2000 PC, it gives the following results for strKey:
AppEvents     (HKEY_USERS\.DEFAULT\AppEvents)
Control Panel     (HKEY_USERS\.DEFAULT\Control Panel)
Environment     (HKEY_USERS\.DEFAULT\Environment)
and so on.

In other words on my Windows 2000 PC, it's reading the keys from a level below where I want, and a level below where it reads them on my XP PC.

Can anyone explain what I'm doing wrong and help me correct the problem so that the script will run correctly on my Windows 2000 PC.
maike13Asked:
Who is Participating?
 
DarkoLordCommented:
0
 
maike13Author Commented:
Wow thanks.  I'll give that a shot.  Should have known Microsoft were behind my problems :-)  This has been driving me crazy.  I don't suppose you have a copy of the hot fix?  It always seems to take Microsoft a couple of days to get around to mailing them.
0
 
maike13Author Commented:
Microsoft were much faster than previously and I now have the hotfix and it works.  The only snag is that, contrary to what MS say in the KB article,  it seems to require a re-boot.  This is a bit of a problem when distributing my code, but I'm hoping I can work around it by stopping and re-starting one of the Services.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.