вторник, 11 мая 2010 г.

HOWTO: Creating an Uninstall Shortcut for an InstallScript MSI Project



As a general rule, Microsoft expect you to uninstall MSI applications from the Add/Remove Programs tool in the Control Panel.
Sometimes however, its nice to add a Start->Programs Menu – ‘Uninstall Shortcut’ to facilitate this action, for user convenience.
The following post details adding such a shortcut to a simple MSI build in Visual Studio 2008.


Browse to the MSI project folder (using Windows Explorer), right click and select New->Shortcut from the context menu. In the Create Shortcut Wizard dialog that pops up type ‘%windir%\system32\msiexec.exe -x {prodCode} ‘ as the location of the shortcut, where prodCode is the Product Code of the MSI package.
create_shortcut_uninstallerproduct_code_uninstaller
This Product Code can be identified from the Project Properties of the MSI Project in Visual Studio. Also, provide a proper name for the shortcut (such as Uninstall “product”, where “product” is the name of the application) and click Finish.
The next step involves adding this shortcut to the User’s Programs Menu folder of the MSI project in Visual Studio. The problem is that files with extension .lnk (extension of the shortcut) cannot be added to the Project.
First we need to rename the shortcut extension from .lnk to .txt. Open up a DOS command window and browse to the location of the shortcut using the ‘cd’ command. Remember to Run as Administrator if you are using Vista!
command_rename_uninstalleruser_programs_uninstaller
Now type ‘ren uninstall.lnk uninstall.txt’ where “uninstall” is the name of the shortcut item. Simply add the renamed shortcut into the User’s Programs Menu folder of the MSI project in the same manner as you would add any other file (Right Click > Add > File). Then in Visual studio Rename the shortcut from .txt back to .lnk and your done.
Build the MSI project and the necessary setup files will be created in the bin folder of the project. Once run the uninstall shortcut will appear in the program menu.

Комментариев нет: