• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 4163
  • Last Modified:

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.
0
maike13
Asked:
maike13
  • 2
1 Solution
 
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

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now