Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

How to Uninstall an Application Programatically using VB.NET

Posted on 2009-04-30
4
Medium Priority
?
1,436 Views
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?
0
Comment
Question by:handyjay
  • 2
  • 2
4 Comments
 
LVL 75

Accepted Solution

by:
käµfm³d   👽 earned 2000 total points
ID: 24270692
The following describes it in C#. I could help translate to VB if necessary.

http://www.experts-exchange.com/Programming/Languages/C_Sharp/Q_23173757.html
0
 

Author Comment

by:handyjay
ID: 24272277
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 = ""
                Else
                    uninstall = obj.ToString()
                End If
                i = Names.Length
            End If
        Next
 
        System.Console.WriteLine(uninstall)
        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
        FProcess.Start()
        System.Console.Read()

Open in new window

0
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 24272377
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.
0
 

Author Closing Comment

by:handyjay
ID: 31576452
Got it.  I was trying to run it from a windows forms application.  It works as a console app.  Thanks
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses
Course of the Month10 days, 10 hours left to enroll

571 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