Solved

How to return a list of software installed on a computer?

Posted on 2004-08-16
5
297 Views
Last Modified: 2010-05-18
I am just wondering is there anyway to return a list of software which installed on a computer. I am currently using WMI (Windows Management Information) classes to retrieve such information as drive, processor and operating system information. Your help would be gratefully appreciated.
0
Comment
Question by:edmundg
  • 2
5 Comments
 
LVL 48

Expert Comment

by:Mikal613
ID: 11809545
Well you can loop through c:\program files and see the current applications
0
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 11809918
It is impossible to list ALL software on a system.

You could certainly determine what programs are listed in the Add/Remove section of the conrol panel but that is not always accurate as sometimes applications get orphaned there even though they were uninstalled long ago.

Additionally, not all programs on a system are listed there.  Any app that doesn't require installation will simply reside on the hard drive somewhere, and not necessarily in the "Program Files" folder either.

With that info in mind...you can duplicate the Add/Remove list by going to this key in the registry:

    HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Uninstall

Then simply enumerate all the entries and fetch the DisplayName value from each one.

Regards,

Idle_Mind
0
 
LVL 7

Accepted Solution

by:
natloz earned 125 total points
ID: 11810601
Here is something I played with...the PRODUCT (search 7) gives you a list of software installed with MSI Installer:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim search1 As New ManagementObjectSearcher("SELECT * FROM Win32_ComputerSystem")
        Dim search2 As New ManagementObjectSearcher("SELECT * FROM Win32_CDROMDrive")
        Dim search3 As New ManagementObjectSearcher("SELECT * FROM Win32_PointingDevice")
        Dim search4 As New ManagementObjectSearcher("SELECT * FROM Win32_Processor")
        Dim search5 As New ManagementObjectSearcher("SELECT * FROM Win32_SystemEnclosure")
        Dim search6 As New ManagementObjectSearcher("SELECT * FROM Win32_OperatingSystem")
        Dim search7 As New ManagementObjectSearcher("SELECT * FROM Win32_Product")

        Dim moInfo As ManagementObject

        For Each moInfo In search1.Get()
            txtInfo.Text = ("Computer: " & moInfo("Name").ToString() & ControlChars.CrLf & _
            "User Name: " & moInfo("UserName").ToString() & ControlChars.CrLf & _
            "Domain: " & moInfo("Domain").ToString() & ControlChars.CrLf & _
            "Total RAM: " & moInfo("TotalPhysicalMemory").ToString() & ControlChars.CrLf & _
            "Processor Count: " & moInfo("NumberOfProcessors").ToString() & ControlChars.CrLf)
        Next moInfo

        For Each moInfo In search2.Get()
            txtInfo.Text = txtInfo.Text + ("CDRom: " & moInfo("Name").ToString() & ControlChars.CrLf)
        Next moInfo

        For Each moInfo In search3.Get()
            txtInfo.Text = txtInfo.Text + ("Mouse: " & moInfo("Name").ToString() & ControlChars.CrLf)
        Next moInfo

        For Each moInfo In search4.Get()
            txtInfo.Text = txtInfo.Text & _
            ("Processor Description: " & moInfo("Description").ToString() & ControlChars.CrLf & _
            "Processor Name: " & moInfo("Name").ToString() & ControlChars.CrLf & _
            "Max Clock Speed: " & moInfo("MaxClockSpeed").ToString() & ControlChars.CrLf)
        Next moInfo

        For Each moInfo In search5.Get()
            txtInfo.Text = txtInfo.Text & _
            ("Manufacturer: " & moInfo("Manufacturer").ToString() & ControlChars.CrLf & _
            "Serial Number: " & moInfo("SerialNumber").ToString() & ControlChars.CrLf)
        Next moInfo

        For Each moInfo In search6.Get()
            txtInfo.Text = txtInfo.Text & _
            ("Operating System: " & moInfo("Name").ToString() & ControlChars.CrLf)
        Next moInfo

        txtInfo.Text = txtInfo.Text + "--------------------" & ControlChars.CrLf

        For Each moInfo In search7.Get()
            txtInfo.Text = txtInfo.Text & ("Product Name: " & moInfo("Name").ToString() & ControlChars.CrLf)
        Next moInfo


    End Sub
0
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 11810640
Here is an example of enumerating the Uninstall key and placing the list into a ListBox:

Imports Microsoft.Win32

Public Class Form1
    Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call

    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    Friend WithEvents ListBox1 As System.Windows.Forms.ListBox
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.ListBox1 = New System.Windows.Forms.ListBox
        Me.SuspendLayout()
        '
        'ListBox1
        '
        Me.ListBox1.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _
                    Or System.Windows.Forms.AnchorStyles.Left) _
                    Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.ListBox1.Location = New System.Drawing.Point(8, 8)
        Me.ListBox1.Name = "ListBox1"
        Me.ListBox1.Size = New System.Drawing.Size(432, 277)
        Me.ListBox1.TabIndex = 0
        '
        'Form1
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.ClientSize = New System.Drawing.Size(448, 294)
        Me.Controls.Add(Me.ListBox1)
        Me.Name = "Form1"
        Me.Text = "Add/Remove Program Listing"
        Me.ResumeLayout(False)

    End Sub

#End Region

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Try
            Dim rk As RegistryKey = Registry.LocalMachine.OpenSubKey("Software\Microsoft\Windows\CurrentVersion\Uninstall")
            Dim sk As String
            Dim appKey As RegistryKey
            Dim displayNameValue As Object
            Dim displayName As String
            ListBox1.Sorted = True
            If Not (rk Is Nothing) Then
                For Each sk In rk.GetSubKeyNames
                    appKey = rk.OpenSubKey(sk)
                    displayNameValue = appKey.GetValue("DisplayName")
                    If Not (displayNameValue Is Nothing) Then
                        ListBox1.Items.Add(CType(displayNameValue, String))
                    End If
                Next
            End If
        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Information, "Error Accessing Registry")
        End Try
    End Sub
End Class
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Advice on Xojo as a development tool over VB. 4 55
Get Client IP on RDS - VB.NET 15 47
VB.NET Repostiory Pattern 7 37
Crystal reports vb.net 2 41
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question