How to programmatically uninstall an application in Windows?

We are releasing a new version of our application, and we would like it to be able to remove the previous installed version from the client computer.

How can we do this?

edit: I install this application (as well as the previous version) with a deployment project in Visual Studio, so I assume it is a Windows installer.

Thanks a bunch!

+4
source share
4 answers

The Visual Studio deployment project has a built-in function to remove previous versions of your application.

Check the RemovePreviousVersions properties in the Deployment Project Properties.

http://msdn.microsoft.com/library/y63fxdw6.aspx

Edit

from MSDN:

The installer checks the UpgradeCode and ProductCode Properties to determine whether to use an earlier version removed. UpgradeCode code should be the same for both versions; ProductCode must be different.

+5
source

If you use a batch or other automatic deployment tool for your releases, you can easily uninstall the MSI product using the following command line:

  msiexec [/ uninstall |  / x] [Product.msi |  ProductCode]
+4
source

The Microsoft Installer format (* .msi) supports what you want to do, unfortunately, Visual Studio offers limited customization and is intended for use in basic projects.

There are many resources in this thread, and many others ask similar questions. My best advice would be to spend some time examining the MSDN documentation.

...

Update

OK Having spent 30 minutes reading several articles, I think that this can be possible with the help of a special action that you pack together with the new installer.

Follow this MSDN article in creating custom actions . This involves creating a new class library, adding the System.Configuration.Install.Installer class, adding it as output to the installation project , and then selecting it as a custom action.

To view the custom actions tab, right-click the installation project and choose View> Custom Actions.

From here: you will need to write code to remove the installation directory and AppData profile. This article on how to set up Custom Activity Data may be helpful.

Good luck.

Hth,

Dennis

+1
source

If you are programming this, then this is a simple reverse part.
Or you can use some kind of installer / installer to uninstall, for example NSIS

0
source

All Articles