Retrieving Registry Keys with VBScript
Posted on 2007-07-24
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
On my Windows XP PC, it works fine, and gives the following results for strKey:
and so on
Hwoever on my Windows 2000 PC, it gives the following results for strKey:
Control Panel (HKEY_USERS\.DEFAULT\Control Panel)
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.