Installed Applications on remote PC in VB.NET
Compared to using a ManagementObjectSearcher this is much faster and will return all installed applications including MS patches.
Dim myServerName As String = “WAADESK1″
Const HKLM = &H80000002 ‘HKEY_LOCAL_MACHINE
Dim reg_hklm, key, subkey As RegistryKey
reg_hklm = RegistryKey.OpenRemoteBaseKey(RegistryHive.LocalMachine, myServerName)
key = reg_hklm.OpenSubKey(“Software\Microsoft\Windows\CurrentVersion\Uninstall”, False)
If Not IsNothing(key) Then
For Each temp In key.GetSubKeyNames()
subkey = key.OpenSubKey(temp, False)
If Not IsNothing(subkey.GetValue(“DisplayName”)) Then
Console.WriteLine(subkey.GetValue(“DisplayName”).ToString)
subkey.Close()
End If
Next
key.Close()
End If
[sourcecode language='vb']
Dim myServerName As String = “WAADESK1″
Dim reg_hklm, key, subkey As RegistryKey
reg_hklm = RegistryKey.OpenRemoteBaseKey(RegistryHive.LocalMachine, myServerName)
key = reg_hklm.OpenSubKey(“Software\Microsoft\Windows\CurrentVersion\Uninstall”, False)
If Not IsNothing(key) Then
For Each temp In key.GetSubKeyNames()
subkey = key.OpenSubKey(temp, False)
If Not IsNothing(subkey.GetValue(“DisplayName”)) Then
Console.WriteLine(subkey.GetValue(“DisplayName”).ToString)
subkey.Close()
End If
Next
key.Close()
End If
[/sourcecode]