views:

104

answers:

4

Hello everybody,

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

How would we be able to do that?

edit: I'm installing this application (and also the previous version) with a deployment project in Visual Studio, so I assume it is a Windows Installer.

Thanks a bunch!

A: 

If this you program then that's a simple reverse batch.
Or you could use some installer/uninstaller builder like NSIS

pinichi
+3  A: 

Deployement Project in Visual Studio has a build-in feature to remove previous versions of your application.

Check the "RemovePreviousVersions" property in the Deployement Project Properties.

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

Edit:

from MSDN:

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

Thomas
If this works, I'm gonna shoot myself and give you a medal. Thanks for the answer, I'll let you know if it works! How do I update the UpgradeCode?
Andrei
I'm not certain that this option will achieve what you want. From the information provided, it sounds like this is the first time the application has been installed using an installer (otherwise, it would have had an uninstaller application that could have been run).
Dennis Roche
Is there any way to trigger some methods before the application removes the previous versions?
Andrei
@Andrei: I mix up UpgradeCode and ProductCode. See edit. @Dennis: from Andrei's question, it looks like the previous version also uses VS deployement project.
Thomas
Those GUID properties are the key to the whole upgrade process in Windows Installer. The quote from MSDN on UpgradeCode and ProductCode should be obeyed to the letter, otherwise you'll end up with unexpectedly broken upgrades.
alastairs
PS: I think you can also use them to control your upgrade process, if you decide not to allow a direct upgrade from version 3 to version 6, for example.
alastairs
This is what I eventually used, so thanks for the answer. Programmatically, I guess this could be done also with what the other people here answered.
Andrei
+1  A: 

The Microsoft Installer (*.msi) format supports what you want do to, unfortunately Visual Studio only offers limited customisation and is designed to be used for basic projects.

There are a lot of resources out there on this topic and many other people asking similar questions. My best advice would be spent some time researching the MSDN documentation.

...

Update

OK. After spending 30 minutes reading a few articles, I think it may be possible using a custom action that you package with your new installer.

Follow this MSDN article on creating a Custom Action. It involves creating a new class library, adding an System.Configuration.Install.Installer class, adding it as an output to the setup project, and then selecting it as a custom action.

To view your custom actions tab, right-click on the setup project and select View > Custom Actions.

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

Good luck.

HTH,

Dennis

Dennis Roche
Thanks for your help Dennis. I do have custom actions set up both for install and uninstall. Problem is that the previous version does not have the same actions set up. Deleting the installation directory will not uninstall the application (as it would from the control panel).
Andrei
@Andrei: From my understand, you should be able to achieve what you want using a custom action. Check if the installation directory exists and AppData profile exists and if so, delete them. If wrote any keys to the registry, find them and delete them. This is only a temporary patch for this version, as next time you will have proper uninstaller to run. Perhaps you should also research your application structure and reconsider your deployment options. BTW: How big is your install base?
Dennis Roche
+2  A: 

If your using batch or another automated deployment tool for your releases, you can easily uninstall an MSI product using the following command line:

 msiexec [/uninstall | /x] [Product.msi | ProductCode]
James - built2order