Enumerating Remote registry key values using VB.NET


Alan King

To All:

I'm having difficulty getting the syntax correct for VB.NET to produce a
listing of all software applications on a remote PC listed in the registry
installed programs.

I'm able to get to the point where I enumerate the keys, but I can't figure
out the syntax for retrieving the values from those keys. Here's what I
have at this point:

////////////////////// BEGINNING OF CODE
Dim strComputerName As String = tbScope.Text
Dim strSubKeyName As String
Dim strValueName As String
Dim strStringValue As String = ""
Dim strValue As String
Dim strKeyPath As String =
Dim objManagementScope As ManagementScope
Dim objManagementClass As ManagementClass
Dim objManagementBaseObject As ManagementBaseObject
Dim aSubKeys() As String

objManagementScope = New ManagementScope
objManagementScope.Path.Server = strComputerName
objManagementScope.Path.NamespacePath = "root\default"
objManagementScope.Options.EnablePrivileges = True
objManagementScope.Options.Impersonation =

objManagementClass = New ManagementClass("stdRegProv")
objManagementClass.Scope = objManagementScope
objManagementBaseObject =
objManagementBaseObject.SetPropertyValue("hDefKey", CType("&H" &
Hex(RegistryHive.LocalMachine), Long))
objManagementBaseObject.SetPropertyValue("sSubKeyName", strKeyPath)
aSubKeys = CType(objManagementClass.InvokeMethod("EnumKey",
objManagementBaseObject, Nothing).Properties.Item("sNames").Value, String())

Dim strkey As String

For Each strkey In aSubKeys
////////////////////// END OF CODE /////////////////////////////////////////

In VBScript, I could use the GetStringValue as shown below to get the
Display name of a application listed in the registry:

"GetStringValue(HKLM, BASE_KEY & strKey, "DisplayName", strDisplayName)"

However, I don't know the .NET version (System.Management) of getting these

If anyone has a recommendation or a code snippet to show how I can do this
in VB.NET it would be greatly welcomed.


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