From: rtm on
I'm trying to get the subkeys into an array which is easlily done via.
wmi, and then read a "value" under each subkey. Here is what I have,
and this works fine as long as I have a "Z" value, but I wanted to get
each subkey in the array to read that value. I thought I could do this
through the "Path =" but am stuck.... can anyone help?


Const HKEY_CURRENT_USER = &H80000001
strComputer = "."

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

strKeyPath = "Network"
oReg.EnumKey HKEY_CURRENT_USER, strKeyPath, arrSubKeys

For Each subkey In arrSubKeys

'***********************************************************************

Set WshShell = CreateObject ("WScript.Shell")
Path = "HKCU\Network\Z\Remotepath"
Value = WSHShell.RegRead (Path)
Wscript.Echo (subkey & ":") & (Value)
Next

From: jamie.r.nelson on
See example below, however, keep in mind it only works for string
values. I use this routine to detect what software is identified in
Add/Remove Programs. You'll have to use a Select Case on arrValueTypes
to determine the type of registry value you're dealing with so that you
can use the appropriate WMI method to retrieve the value.

Const HKEY_LOCAL_MACHINE = &H80000002
strKeyPath = "Software\Microsoft\Windows\CurrentVersion\Uninstall"
Set objReg =
GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv")
objReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys
If IsArray(arrSubKeys) Then
For Each Subkey in arrSubKeys
strExpKeyPath = strKeyPath & "\" & Subkey
objReg.EnumValues HKEY_LOCAL_MACHINE, strExpKeyPath, arrEntryNames,
arrValueTypes
If IsArray(arrEntryNames) Then
For i = 0 To UBound(arrEntryNames)
strEntryName = arrEntryNames(i)
objReg.GetStringValue HKEY_LOCAL_MACHINE, strExpKeyPath,
arrEntryNames(i), strValue
WScript.Echo "Value Name: " & strEntry & VbCrLf & _
"Value: " & strValue
Next
End If
Next
End If
Set objReg = Nothing


rtm wrote:
> I'm trying to get the subkeys into an array which is easlily done via.
> wmi, and then read a "value" under each subkey. Here is what I have,
> and this works fine as long as I have a "Z" value, but I wanted to get
> each subkey in the array to read that value. I thought I could do this
> through the "Path =" but am stuck.... can anyone help?
>
>
> Const HKEY_CURRENT_USER = &H80000001
> strComputer = "."
>
> Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
> strComputer & "\root\default:StdRegProv")
>
> strKeyPath = "Network"
> oReg.EnumKey HKEY_CURRENT_USER, strKeyPath, arrSubKeys
>
> For Each subkey In arrSubKeys
>
> '***********************************************************************
>
> Set WshShell = CreateObject ("WScript.Shell")
> Path = "HKCU\Network\Z\Remotepath"
> Value = WSHShell.RegRead (Path)
> Wscript.Echo (subkey & ":") & (Value)
> Next

From: rtm on

Thanks, but I didn't get your code to work...

I did adjust the path to the following which gave me the output I was
looking for:

Path = "HKCU\Network\" & subkey & "\Remotepath"