How To Get Installed Applications In VB.NET

you can even make this application like something which is used to uninstall applications by the way i just made this simple because you all should understand the basics of this so hope you understand what this actually is , lets make this . just open visual basic 2008/2010 and create a new project and select windows applications(windows forms application) after form loaded go to form properties and edit things what you do usually , now go to toolbox and drag and drop a listview tool into the form and go to listview properties and select columns and a small windows will popup , on the windows click add two times to add two columns
columnheader


now change column text ,ColumnHeader1 change the text to Name and change the text of ColumnHeader2 to Uninstall Path and click ok , make your form look like this

app look

now double click your form and add this code

Imports Microsoft.Win32
Public Class Form1

    'Author : Mohamed Shimran
    'Blog : http://www.ultimateprogrammingtutorials.blogspot.com

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        For Each AI As AppInfo In GetInstalledApps()
            If AI.UnInstallPath IsNot Nothing Then
                Dim LI As New ListViewItem
                LI.Text = AI.Name
                LI.SubItems.Add(AI.UnInstallPath.Replace("""", ""))
                LI.SubItems.Add(AI.SilentUnInstallPath)
                ListView1.Items.Add(LI)
            End If
        Next
    End Sub
    Structure AppInfo
        Dim Name As String
        Dim UnInstallPath As String
        Dim SilentUnInstallPath As String
    End Structure
    Function GetInstalledApps() As List(Of AppInfo)
        Dim DestKey As String = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\"
        Dim iList As New List(Of AppInfo)
        For Each App As String In Registry.LocalMachine.OpenSubKey(DestKey).GetSubKeyNames
            iList.Add(New AppInfo With {.Name = Registry.LocalMachine.OpenSubKey(DestKey & App & "\").GetValue("DisplayName"), _
                       .UnInstallPath = Registry.LocalMachine.OpenSubKey(DestKey & App & "\").GetValue("UninstallString")})
        Next
        Return iList
    End Function
End Class

now debug

preview - 

Get installed apps preview

11 comments

dude,
I am in search of creating the installer.

I think that: my files that should be placed will be stored in resource folder.
And when I click install on the main form (installer)
all the files will be copy and paste to the installation directory (textbox1)

but the problem remain that:
How can I add my application in the installed app.
and how to create uninstaller for this (which delete all the files and delete itself at the end)

Reply me soon

Reply

Hello,

I think you should use an installer creator rather than making one for yourself, look here for a list of installer creators http://en.wikipedia.org/wiki/List_of_installation_software

Reply

I'm programmer located in Italy. I'm going to use your code. Thanks!

Reply

Nice code, i've been following you! thank you.

Reply

Brilliant - and simple. Thanks!

Reply

Wow this is great. Im having a problem reading all installed programs on my machine. Im not sure its its because they were installed and put in the Programs x64 folder or if they just dont show up. Everything it reads in the registry is correct but I guess what im trying to do is read all the uninstallers for all programs installed. Could I do that using this same code?

Reply

Hey ,

You can try this. Create a new project and add your stuff. Now you can copy the files to be copied in the root of the assembly. You can add a event of by clicking on the button it will copy the files to the directory and then you can add a event to add a registry string and a key with your install dir on it (receive from textbox) and icon or something. And now to hide your code and files to install , use a packager like boxedpacker.

Reply

Mate, I would like to share this in my blog. With your credit ofcourse. :)

Reply

Good sample... small, uses the framework and gets the desired results. Thanks!

Reply

Nice one, tried, do some mod, got my desired result....thanks so much...

Reply

Post a Comment