I'm trying to retrieve values from a remote registry. I have successfully connected to the remote computer using WMI (system.management).
I have an error in my code below.
Does anyone see the error in my code?? Nothing ever gets set into Values.
I have an error in my code below.
Visual Basic:
Dim strKeyPath As String = "Software\VB and VBA Program Settings\Current"
Dim Values() As String
Dim options As New ConnectionOptions
options.Username = "username"
options.Password = "password"
Dim scope As New ManagementScope("\\" + PCname + "\root\default", options)
scope.Options.EnablePrivileges = True
scope.Options.Impersonation = ImpersonationLevel.Impersonate
scope.Connect()
If scope.IsConnected Then
'Dim objClass As New ManagementClass(scope, New ManagementPath("StdRegProv"), Nothing)
Dim objClass As New ManagementClass("StdRegProv")
objClass.Scope = scope
Dim objBase As ManagementBaseObject
objBase = objClass.GetMethodParameters("GetStringValue")
objBase.SetPropertyValue("hDefKey", CType("&H" & Hex(RegistryHive.CurrentUser), Long))
objBase.SetPropertyValue("sSubKeyName", strKeyPath)
objBase.SetPropertyValue("sValueName", "Name")
objBase = objClass.InvokeMethod("GetStringValue", objBase, Nothing)
Values = CType(objBase.Properties.Item("sValue").Value, String())
Does anyone see the error in my code?? Nothing ever gets set into Values.
Last edited by a moderator: