473,386 Members | 1,793 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Querying a remote machine registry using WMI and VB.NET

JJG
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 posted this one also to the
win32.programmer.wmi forum).

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

Nov 21 '05 #1
1 13344
Hi,

Try using impersonation to use RegistryKey.OpenRemoteBaseKey

http://www.dotnet247.com/247referenc...28/144136.aspx

Ken
----------------
"JJG" <JJ*@discussions.microsoft.com> wrote in message
news:8C**********************************@microsof t.com...
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 posted this one also to the
win32.programmer.wmi forum).

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
Nov 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Cherry | last post by:
Hi, can I access the registry of a remote machine using VB.NET? While connecting to the remote machine I would be using the admin login of that machine. Thanks.
6
by: deko | last post by:
In a multi-user environment, I have a table that stores hyperlinks to documents that are stored on the machine that hosts the mdb database. The table entry looks like this: ...
1
by: Andrew | last post by:
Hey all, Working on revamping our Intranet here and making use of the LDPA, Active Directory, Directory Services, etc. that .Net provides. I am still fairly new on this subject, so the problem...
3
by: Steve Montgomery | last post by:
Does anyone have a sample block of code they can share for checking a DWORD value on a remote network machine's registry? For example, to validate a patch deployment. MSDN has a great sample for...
3
by: Geoff McElhanon | last post by:
I have been struggling with a security issue that occurs under .NET 2.0, but does not occur under .NET 1.1. Essentially I am trying to open up a performance counter on a remote server and monitor...
5
by: Sin Jeong-hun | last post by:
I need to read some registry keys of a remote computer. The key will be any key users provide. (For example : HKEY_CURRENT_USER\SOFTWARE \MyGame) I found that there was a handy method called...
3
by: JB | last post by:
I am trying to access a registry key on computer like so: key = RegistryKey.OpenRemoteBaseKey(RegistryHive.LocalMachine, computerName).OpenSubKey(Subkey); There are two keys I am trying to...
8
by: Hayato Iriumi | last post by:
Hello, folks. I have a need to get the value of %windir% on a remote machine. Is it possible to get this value using C#?
12
by: =?Utf-8?B?YXVsZGg=?= | last post by:
i current have a way to read both local and remote machines registry keys and create a textual view (.txt output). i now looking for ways to do export of local and remote mahcine registry keys...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.