Hello. I'm not sure if this is the right forum, so please let me know what
is the correct one if it isn't.
I've been puzzled by this a for a few days. I'm trying to read a registry
value from a remote system's registry using WMI (System.Management). I'm
able to connect to the system and even run a process, but I cannot figure out
what is I have to do to get the StdRegProv process. Here is what I am doing:
Dim wmiOptions As New ConnectionOptions
wmiOptions.Username = "username" 'Administrator's login and pwd.
wmiOptions.Password = "password"
wmiOptions.Impersonation = ImpersonationLevel.Impersonate
Dim wmiScope as New ManagementScope("\\" & pAddress & "\root\cimv2",
wmiOptions)
Dim wmiPath As New ManagementPath("Win32_Service")
Dim processClass As New ManagementClass(wmiScope, wmiPath, Nothing)
Dim inParams As ManagementBaseObject =
processClass.GetMethodParameters("GetStringValue")
I know that the inParams fails because I have the Win32_Service, not the
StdRegProv, but how do I get the StdRegProv?
I tried querying instead of instanciating the ManagementClass directly, but
I get nothing returned:
Dim query As New SelectQuery("Win32_Service", "Name='StdRegProv'")
Dim searcher As New ManagementObjectSearcher(wmiScope, query)
Dim envVar As ManagementBaseObject
For Each envVar In searcher.Get()
... <-- There is nothing in envVar.
Next
I am using WMI because although I don't have domain rights to the systems
(otherwise I'd use RegistryKey.OpenRemoteBaseKey...although if anyone can
tell me how to use this with a provided username/password, it would be
great), I have usernames/passwords with administrator rights. I was able to
create a process remotely, so I know that access rights is not the problem.
Any help, alternative method, or pointer to a solution would be appreciated.
JJG