5

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!

3
  • 3
    What installation technology are you using? Windows Installer? NSIS? Something else? Commented Oct 13, 2010 at 9:25
  • Do you already have an uninstaller for your application? What type of data do you need to rollback in order for you to perform a clean install? Commented Oct 13, 2010 at 9:29
  • @alastairs: see edit @Dennis: I don't have an uninstaller. Basically I should delete the whole program files folder plus some other folders I'm using in the user's AppData profile. Commented Oct 13, 2010 at 9:31

4 Answers 4

6

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.

Sign up to request clarification or add additional context in comments.

7 Comments

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?
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).
Is there any way to trigger some methods before the application removes the previous versions?
@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.
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.
|
5

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]

1 Comment

Hey James. +1 for what I want to do, but I also want my application to be able to "grab" my ProductCode without me having to go in and manually hard code that every time I make a software update. Any idea how to do that?
1

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

2 Comments

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: 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?
0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.