views:

334

answers:

1

If I have a registry pathing of:

HKEY_LOCAL_MACHINE\SOFTWARE\INTERSTAR\XFILES\CONFIG MANAGER\SYSTEM\COMPANIES

How would I go about listing all the records under that path/directory and access the DWORDs, REG_SZs and data?

thanks in advance

+5  A: 

One option would be to use WMI:

Const HKEY_LOCAL_MACHINE = &H80000002

strComputer = "."

Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _ 
    strComputer & "\root\default:StdRegProv")

strKeyPath = "SYSTEM\CurrentControlSet\Services"
oReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys

For Each subkey In arrSubKeys
    Wscript.Echo subkey
Next

You will find more useful registry scripts here: http://www.activexperts.com/activmonitor/windowsmanagement/scripts/operatingsystem/registry/

0xA3
In fact I'm not aware of any *other* way to do Registry enumeration within Windows script. None that would work without installing third-party dependencies beforehand at least. +1
Tomalak
Actually I'm neither aware of any other way, although it seems a little strange that there isn't a more "native" way to do it.
0xA3
If you look at it strictly, there is next to nothing you can do with "native" VBScript. The language was build to use COM objects extensively and painlessly, so you could say that using a COM object *is* the native way of getting things done in VBScript.
Tomalak
Yes, true. But since COM still is *the* component model of Windows one would expect to have COM objects available for basic things such as registry access. WMI seems rather heavy-weight for that job...
0xA3
Oh, that. ;-) You are right, I always wondered myself why they never made a registry pendant of the FileSystemObject. Would not have been too hard, I guess.
Tomalak
Powershell is the more *native* way to do it IMO. This line would do it in PS: GCI "HKLM:\SOFTWARE\INTERSTAR\XFILES\CONFIG MANAGER\SYSTEM\COMPANIES"
EBGreen
Having said tht however, this answer is the right one for VBS. +1
EBGreen