Reputation: 53
I have one script retrieve all registry values in a specific key (Ex: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ASP.NET
), but I need consult in making that search recursive. I need print all registry and subkeys below this key (Ex: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ASP.NET
)
Example for my script:
For Each strSubkey In arrSubKeys
Set objHtml=fso.Opentextfile(strComputer & ".txt",intForWriting,Createfile)
strValue = Null
strSubKeyPath = pathKeyReg & "\" & strSubkey
objRegistry.EnumValues hDefKey, strSubKeyPath, arrValueNames, arrTypes
For i = LBound(arrValueNames) To UBound(arrValueNames)
strValueName = arrValueNames(i)
Select Case arrTypes(i)
Case REG_SZ
objRegistry.GetStringValue hDefKey, strSubKeyPath, strValueName, strValue
objHtml.WriteLine strSubKeyPath & vbTab & strValueName & vbTab & "(REG_SZ)" & vbTab & strValue
' Show a REG_EXPAND_SZ value
Case REG_EXPAND_SZ
objRegistry.GetExpandedStringValue hDefKey, strSubKeyPath, strValueName, strValue
objHtml.Write strSubKeyPath & vbTab & strValueName & vbTab & "(REG_EXPAND_SZ)" & vbTab & strValue
End Select
Next
Next
Upvotes: 1
Views: 118
Reputation: 200293
You need to recurse into subkeys for that. Wrap your code in a procedure and add code that enumerates the subkeys of the current key and calls itself for each subkey.
Sub RecurseKey(key)
'enumerate values (your existing code)
objRegistry.EnumValues hDefKey, key, names, types
If Not IsNull(names) Then
For i = 0 To UBound(names)
name = names(i)
Select Case types(i)
Case REG_SZ
...
Case REG_EXPAND_SZ
...
Case ...
End Select
Next
End If
'enumerate subkeys and recurse
objRegistry.EnumKey hDefKey, key, subKeys
If Not IsNull(subKeys) Then
For Each sk In subKeys
RecurseKey key & "\" & sk '<-- recursion happens here
Next
End If
End Sub
Upvotes: 1