Read remote registry

S

Slimo

Hello,

I'm searching some example of code (VB) for reading remote registry subkeys
and keys.

Thanks
 
S

Slimo

The following code read registry for the local computer; How to change it to
read registry from remote computer?

Imports Microsoft.Win32

Module Module1

Sub Main()

' Open the Uninstall registry subkey.
Dim Key As RegistryKey = Registry.LocalMachine.OpenSubKey _
("SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall", False)
' Retrieve a list of installed software products.
' This list also includes some software products that are not valid.
Dim SubKeyNames() As String = Key.GetSubKeyNames()
' Declare a variable to iterate through the retrieved list of
' installed software products.
Dim Index As Integer
' Declare a variable to hold the registry subkey that correspond
' to each retrieved software product.
Dim SubKey As RegistryKey
Console.WriteLine("The following software products are installed on
this computer:")
Console.WriteLine("")
' Iterate through the retrieved software products.
For Index = 0 To Key.SubKeyCount - 1
' Open the registry subkey that corresponds to the current
software product.
' SubKeyNames(Index) contains the name of the node that
corresponds to the
' current software product.
SubKey = Registry.LocalMachine.OpenSubKey _
("SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" + "\"
_
+ SubKeyNames(Index), False)
' Verify that the DisplayName exists. If the DisplayName does
not exist,
' return a null string. If the returned value is a null string,
the
' DisplayName does not exist, and the software product is not
valid.
If Not SubKey.GetValue("DisplayName", "") Is "" Then
' The current software product is valid.
' Display the DisplayName of this valid software product.
Console.WriteLine(CType(SubKey.GetValue("DisplayName", ""),
String))
End If
Next

Console.WriteLine("Press ENTER to quit.")
Console.ReadLine()

End Sub

End Module
 
S

Steve C. Orr [MVP, MCSD]

You need to run this code on the client. Of course the client will need the
..NET framework installed and there will be layers of security you'll have to
deal with. (I know I wouldn't want just any web site reading my registry.)

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
Hire top-notch developers at http://www.able-consulting.com
 
S

Slimo

This is to collect data from a LAN (inventory the software installed on the
computers in an domain)
 
Joined
Nov 2, 2007
Messages
1
Reaction score
0
This solution may not be helpful for the original member, but might help you!

To connect to remote computer:

Instead of using:
Registry.LocalMachine.OpenSubKey("KEY_PATH", True)

Use:

RegistryKey.OpenRemoteBaseKey(RegistryHive.LocalMachine, "REMOTE_COMPUTER_NAME").OpenSubKey("KEY_PATH")

You may need to change RegistryHive value based on your situation

I hope this helps!!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top