How to add an uninstall shortcut · 29 December 2005, 16:43

Although Microsoft frowns on this practice it is popular for a program to provide a link to uninstall the program in its program menu. Conceptually this is simple. You just want to create a shortcut to the command:

msiexec.exe /x (product code guid)

This should not be to hard. msiexec.exe should be on the machine otherwise your installer would not work at all. Even better the product code guid is available in the installer as a variable [ProductCode]. There’s one tiny problem. Visual Studio does not want to let you create a shortcut to a file that’s not in the install image.

So unfortunately you have to resort to a hack. The most popular one seems to be to create a batch file to run msiexec for you. Although ugly and risking bringing up a security warning depending on how the machine is step up here’s how to do it:

1) Create a batch file uninstall.bat with the command

”%SystemRoot%System32msiexec.exe” /x %1

in it.
2) Add it to “Application Folder” virtual folder in the setup project
3) Create a shortcut to Uninstall.bat. Rename it to be whatever you want and change it’s icon to be what you want.
4) In the Shortcut’s property grid change the Arguments field to be [ProductCode].
5) Move the shortcut to the User’s Program Menu group.

Ugly but it seems to work for the current generation of windows.

* * *