Click to See Complete Forum and Search --> : Find a Registry entry on remote server using WMI


pragya.mishra
07-24-2006, 12:32 AM
Hi ,

I have registered a dll on remote machine and I want to search the registry entry on the remote server. I am using the the code below but its not working correctly.Please Help!!.

Public Enum RegRootKeys
HKEY_CLASSES_ROOT = &H80000000
HKEY_CURRENT_USER = &H80000001
HKEY_LOCAL_MACHINE = &H80000002
HKEY_USERS = &H80000003
HKEY_PERFORMANCE_DATA = &H80000004
HKEY_CURRENT_CONFIG = &H80000005
HKEY_DYN_DATA = &H80000006
End Enum

Private Sub Command1_Click()
Dim objRemoteReg As Object
Dim strKeyPath As Variant
Dim StrEntryToFind As String
Dim arrSubKeys() As Variant
Dim arrSubKeys1() As Variant
Dim arrValueNames() As String
Dim arrValueTypes() As Variant
Dim subkey As Variant
Dim subkey1 As Variant
Dim objReg1 As Object
Dim sValue As String
Dim i As Integer
Dim j As Integer
Dim blnFoundEntry As Boolean
blnFoundEntry = False
Dim strServer As String
Dim strFile As String
strServer = "10.207.7.80"

Set objRemoteReg = GetObject("winmgmts:" & "\\" & strServer & "\root\default:StdRegProv")
'Mention Key Path Where to Search for keys to get Value Data for this file
strKeyPath = "Software\Classes\CLSID"
StrEntryToFind = "\\" & strServer & "\" & "C:\RTC" & "\" & "TestDll2.dll"
' On Error Resume Next
objRemoteReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys
For Each subkey In arrSubKeys
Debug.Print subkey
objRemoteReg.EnumValues HKEY_LOCAL_MACHINE, strKeyPath & "\" & subkey, arrValueNames, arrValueTypes
For j = 0 To UBound(arrValueNames)
objRemoteReg.GetStringValue HKEY_LOCAL_MACHINE, subkey, arrValueNames(j), sValue
Debug.Print sValue
If sValue = StrEntryToFind Then
blnFoundEntry = True
Exit For
End If
Next
If blnFoundEntry = True Then Exit For
Next
MsgBox "finiish"
End Sub


Thanks Pragya.

gunderstone
07-24-2006, 09:08 AM
Hi pragya.mishra

I am trying to walk through this code - can you tell me if you got this from another source and if so where it is (URL?)

Thanks

ua549
07-25-2006, 07:15 AM
If this does not need to be automated, you can connect to the remote registry from regedit and do a manual search.

pragya.mishra
08-29-2006, 07:21 AM
Hi

Any luck on this , sometime code gives RPC failure at the line, I have highlighted.
Please Help!!