Jump to content
Xtreme .Net Talk

Recommended Posts

Posted (edited)

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.

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.

Edited by PlausiblyDamp

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...