There is something you are not telling me or there is somefundamental issue with the computer names.
I think this could be the issue:
replace the functio with the following version.
In the original example I had defined HKLM as a Const but I don't see it in your code. It should be a pass through anyway.
Code: Select all
Function ListSubKeys( sComputer, iKey, strKey, sKeyLookup, sKeyContent)
On Error GoTo 0 ' be sure error cause us to quit.
Set objReg = GetObject("winmgmts:" & sComputer & "rootdefault:StdRegProv")
objReg.EnumKey HKLM, strKey, arrSubkeys
If IsArray(arrSubkeys) Then
For Each strSubkey In arrSubkeys
objReg.EnumValues iKey,strKey & "" & strSubkey,arrValues,arrTypes
If isArray(arrValues) Then
For i = 0 To Ubound(arrValues)
Select Case arrTypes(i)
Case REG_SZ
If arrValues(i) = sKeyLookup Then
objReg.GetStringValue iKey, strKey & "" & strSubkey, arrValues(i), strValue1
If InStr(strValue1, sKeyContent) Then
'WScript.Echo "REG_SZ[ & arrValues(i) & ]" & "[ & strValue1 & ]"
ListSubKeys = strValue1
Exit Function ' we got teh match so return with it
End If
End If
Case Else ' only interested in strings right now
'WScript.Echo arrTypes(i)
End Select
Next
End If
ListSubKeys = ListSubKeys( iKey, strkey & "" & strSubKey, sKeyLookup, sKeyContent)
If Not IsEmpty( ListSubKeys ) Then
Exit Function
End If
Next
End If
End Function
If you didn't write it perhaps it soes not work the way you think.
I cannot vouch for the remainder of the code as there is no way for me to test this. You need to run it under the debugger on the target system.