How to add a Uninstall option in Visual Studio Setup project without writing code

Using Visual Studio 2005/2008, you don’t need to write any code to add a uninstall option for a Setup project (Yes I know some people can write code to do it)

1) In the Setup Project –> File System windows –> Right Click “File System on Target machine” –> add a Special Folder, select System Folder;

2) Into this system folder Add a file. Browse for msiexec.exe from local System32 folder and add it. Override default properties of this file as follows:

Condition:=Not Installed (make sure you put ‘Not Installed’ exactly like that, same case and everything),

3) Create a new shortcut under the ‘Users Program Menu’, Set Target to the System Folder which you created in the step 1. and point it’s at the msiexec.exe. Rename the shortcut to ‘Uninstall Your Application’. Set the Arguments property to /x{space}[ProductCode].

5) Build the project, ignore warning about the fact that msiexec should be excluded, DONT exclude it or the setup project wont build.

The ‘Not Installed’ condition and Permananet:=True ensure that the msiexec.exe is only placed into the system folder as part of the install IF it doesn’t aready exist, and it is not removed on an uninstall – therefore it;s pretty safe to ignore that warning and just go for it.

(Based on the description from SlapHead)

11 thoughts on “How to add a Uninstall option in Visual Studio Setup project without writing code”

  1. This method works if the version of the msiexec.exe file inside the package is less than or equal to the one present in the target machine. If not (i.e. using a Vista file in the installer and launching the msi on an XP machine) the installer complains about not being able to upgrade the msiexec.exe, a message box is shown and you have to ignore the error to continue.

    To avoid this situation, just use the lowest file version you can find. I added to the installer the msiexec.exe from an XP SP3 machine (4.5.6001.22159) and it seems to work… at least so far…

  2. Hi,
    I created a deployment project using visual studio 2005 for our app.
    And earlier installer version of this app was created using install shield.
    Now, I followed all the steps mentioned in the above thread, but yet exe installed by the installshield does not get uninstalled and when i install my version it shows me multiple instances in the add/remove application folder.
    Any help is really appretiated.

    Thanks….. S

  3. It works with any version of msiexec.exe if the condition is “NOT Installed” (“NOT” is all caps). This way, the installer will not try to upgrade the file.

  4. Hi ,
    How to uninstall an windows setup application using C# in Microsoft Visual Studio 2005

  5. I’m such a newbie when it comes to all this, thanks for taking the time to write this up, keep them coming! How to add a Uninstall option in Visual Studio Setup project without writing code was a wonderful read.

  6. Hello

    How can i add an installer .exe of (for example) videolan to my setup project. Particulary i want at installation start, my setup understand if videolan is alredy installed on pc and if not it install it. I want also that the installation recognize if in the pc is alredy installed my program and if yes, it update it. Someone say how?

    Thank’s alot

  7. My solution for msiexec version problem was creating prior to building and linking an empty .txt document and renaming it ‘msiexec.exe’ everything else remained the same. Since there is no version information included in this dummy file, Windows considers it inferior anyway and falls surely into ‘not installed’ condition.

Leave a Reply

Your email address will not be published. Required fields are marked *