Link to home
Start Free TrialLog in
Avatar of maike13
maike13Flag for United States of America

asked on

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.
ASKER CERTIFIED SOLUTION
Avatar of DarkoLord
DarkoLord
Flag of Slovenia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of maike13

ASKER

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.
Avatar of maike13

ASKER

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.