MAKEMSI quickly and reliably creates MSI files in a non-programmatic way
Have your say! Join the MAKEMSI discussion list or view archive! Suggest improvements. No question too simple or too complex.
[Bottom][Contents][Prev]: Twin Dialogs[Next]: Version Number in Dialog Titles
Have your say! Join the MAKEMSI discussion list or view archive! Suggest improvements. No question too simple or too complex.
\->Tips and Tricks->User Interface Tips->Uninstall Shortcuts

Uninstall Shortcuts

People like uninstall shortcuts as it makes it easier to uninstall a product however Microsoft want users to use the Add/Remove Applet instead.

As I've been asked how to create these in the past and then I saw this blog entryThis external link was OK when tested at 13 Sep 2008 I decided to improve on my previous example while creating a reusable "command".

The following shows how the uninstall shortcut macro (defined below) can be called. The code is included in the "TryMeShortcuts.MM" sample that MAKEMSI installed. Note that the directory key for the shortcut location is passed:

<$UninstallShortcut SCDIR="MY_SHORTCUT_FOLDER" Icon="@.\TryMe.ico">
;<$UninstallShortcut SCDIR="MY_SHORTCUT_FOLDER" Icon="@.\TryMe.ico" Maint='N' Args="/qb">  ;;Direct Uninstall, Don't confirm (NOT recommended)

The following defined the macro the above example uses, this should be placed into a common header file:

#(
    ;--- Note that MS don't like, they want you to go via Add-Remove Applet ---
    #define UninstallShortcut               ;;Version 07.119

    ;--- Make PER-MACHINE (practical) or PER-USER (keep MS happy) component? ---
    #if ['{$LOGO=^N^ $$UPPER}' = 'Y']
        ;--- Create PER-USER component (For LOGO, keep Microsoft happy) -----
        #define+ @@CU  Y
        #define+ @@LM  N
    #elseif
        ;--- Create PER-MACHINE component (less annoying for multiple users) ---
        #define+ @@CU  N
        #define+ @@LM  Y
    #endif

    ;--- Direct Uninstall or Maintenance Dialog (preferred & default)? ------
    #if ['{$Maint=^Y^ $$UPPER}' = 'N']
        ;--- Direct Uninstall (no repair options etc) -----------------------
        #define+ @@What       Uninstall
        #define+ @@WhatSwitch /x
    #elseif
        ;--- The Default, use maintenance dialog (can choose remove) --------
        #define+ @@What       Maintain
        #define+ @@WhatSwitch /i
    #endif

    ;--- Define the component -----------------------------------------------
    <$Component "UninstallShortcut" Create="Y" Directory_="<$AnyDir>" LM="<$@@LM>"  CU="<$@@CU>">
        ;--- Create shortcut (unfortunately ICE lac of smarts will interpret as PER-USER) ---
        #(
            <$Shortcut
                       Dir="[{$SCDIR}]"
                     Title=^{$Title=~<$@@What> <$ProdInfo.ProductName>~}^
                      Icon="{$Icon=^.\<$@@What>Shortcut.ico^}"
                    Target="[System64Folder]msiexec.exe"                   ;;Windows Installer EXE
                 Arguments=^<$@@WhatSwitch> [ProductCode] {$Args=''}^      ;;Maint/Uninstall switch and product code (plus possible extra user parms)
               Description=^{$ToolTip=~<$@@What>s <$ProdInfo.ProductName> version <$ProductVersion>~}^
            >
        #)

        ;--- No need to ignore ICE messages if creating as per LOGO requirements ---
        #if ['{$LOGO $$UPPER}' <> 'Y']
            ;--- Installed PER-MACHINE, Stop the whinging... ----------------
            <$MsiValFilter "Component UninstallShortcut has non-advertised shortcuts. It's KeyPath registry key should fall under HKCU"  Comment=^Not true, this MSI installs per-machine^>
            <$MsiValFilter "Component 'UninstallShortcut' has both per-user and per-machine data with a per-machine KeyPath"             Comment=^Not true, this MSI installs per-machine^>
        #endif
    <$/Component>
#)


Microsoft awarded me an MVP (Most Valuable Professional award) in 2004, 2005, 2006 & 2007 for the Windows SDK (Windows Installer) area.This external link was OK when tested at 9 Sep 2008Please email me any feedback, additional information or corrections.
See this page online (look for updates)

[Top][Contents][Prev]: Twin Dialogs[Next]: Version Number in Dialog Titles


MAKEMSI© is (C)opyright Dennis Bareis 2003-2008 (All rights reserved).
Saturday September 13 2008 at 2:32pm
Visit MAKEMSI's Home PageThis external link was OK when tested at 28 Aug 2008

HTML page dated Mon, 29 Jan 2007 00:11:11 GMT
Microsoft awarded me an MVP (Most Valuable Professional award) in 2004, 2005, 2006 & 2007 for the Windows SDK (Windows Installer) area.This external link was OK when tested at 9 Sep 2008