How to Uninstall an Application Programatically using VB.NET

Posted on 2009-04-30
Last Modified: 2013-11-26
I need to uninstall an application from the local xp PC computers at our company.  There are over 30 computers so I want to write a program in VB.NET using visual studio 2008 to do it for me.

How do I programatically uninstall an application from a users computers using VB.NET?
Question by:handyjay
    LVL 74

    Accepted Solution

    The following describes it in C#. I could help translate to VB if necessary.

    Author Comment

    I converted it... but Im not sure what to enter in the variable sections to make sure I uninstallt he right program
      Dim Fregistry As Microsoft.Win32.RegistryKey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("SOFTWARE").OpenSubKey("Microsoft").OpenSubKey("Windows").OpenSubKey("CurrentVersion").OpenSubKey("Installer").OpenSubKey("UserData").OpenSubKey("S-1-5-18").OpenSubKey("Products")
            Dim Names As String() = Fregistry.GetSubKeyNames()
            Dim uninstall As String = ""
            Dim ApplicationName As String = "Adobe Reader 7.0.8"
            For i As Integer = 0 To Names.Length - 1
                Dim FTemp As Microsoft.Win32.RegistryKey = Fregistry.OpenSubKey(Names(i)).OpenSubKey("InstallProperties")
                If FTemp.GetValue("DisplayName").ToString() = ApplicationName Then
                    Dim obj As Object = FTemp.GetValue("UninstallString")
                    If obj Is Nothing Then
                        uninstall = ""
                        uninstall = obj.ToString()
                    End If
                    i = Names.Length
                End If
            Dim FProcess As New System.Diagnostics.Process()
            Dim temp As String = "/x{" & uninstall.Split("/".ToCharArray())(1).Split("I{".ToCharArray())(2)
            'replacing with /x with /i would cause another popup of the application uninstall 
            FProcess.StartInfo.FileName = uninstall.Split("/".ToCharArray())(0)
            FProcess.StartInfo.Arguments = temp
            FProcess.StartInfo.UseShellExecute = False

    Open in new window

    LVL 74

    Expert Comment

    by:käµfm³d 👽
    Well, line 4 "ApplicationName" would most likely need to be changed (unless of course you are trying to uninstall Adobe). Other than that, I don't believe anything else needs modification.

    Author Closing Comment

    Got it.  I was trying to run it from a windows forms application.  It works as a console app.  Thanks

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    It seems a simple enough task, yet I see repeated questions asking how to do it: how to pass data between two forms. In this article, I will show you the different mechanisms available for you to do just that. This article is directed towards the .N…
    It’s quite interesting for me as I worked with Excel using for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
    Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

    760 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

    Need Help in Real-Time?

    Connect with top rated Experts

    7 Experts available now in Live!

    Get 1:1 Help Now