Uninstall Product action
The Uninstall Program action checks for the presence of a registered uninstaller for any program, and optionally runs the uninstaller or fails the installation. You can use this action to uninstall the previous version of your product or related products, or to detect the presence of a conflicting product and prevent installation of your product.
Uninstaller detection searches the Software\Microsoft\Windows\CurrentVersion\Uninstall registry keys under HKEY_LOCAL_MACHINE and HKEY_CURRENT_USER, in that order. If the desired installer is found and must be executed, InstallMate first tries to use the QuietUninstallString command line; if that is not defined, it will use UninstallString instead.
Note: From version 9.42.0 onward, InstallMate will automatically generate the appropriate uninstallation command line for MSI-based installers if both the QuietUninstallString and the UninstallString commands are missing or empty for the given uninstall key. In that case, a diagnostic message TSU:A0069 will be logged in the installation log file.
For synchronous actions (see Time out below), the installer stores the uninstaller's exit code in the LastExitCode variable; you can use this variable in the conditions of subsequent actions. The exit code is one of the following:
- If the uninstaller is not present, LastExitCode is set to 0 (zero).
- Else if the uninstaller is present but cannot be executed (see Uninstall type below), LastExitCode is set to 1638 (ERROR_PRODUCT_VERSION).
- Else if an error occurs when the uninstaller is started, LastExitCode is set to the (nonzero) Windows error code.
- Else if the action terminates prematurely due to a time-out, LastExitCode is set to 259 (STILL_ACTIVE).
- Else if a secondary process is specified (see Process 2 below), its exit code is stored.
- Else the exit code of the uninstaller itself is stored.
For asynchronous actions, LastExitCode is set to 0 if the uninstaller was started successfully, or to a nonzero Windows error code if an error occurred while starting the program.
The following attributes and options are available.
|Action name||Enter the name of the action. This name is only used in InstallMate and is not visible to the user.|
Select the uninstallation type from the drop-down list. The following choices are available:
Uninstallation behavior differs depending on the installer's TsuQuiet level:
Enter the uninstaller registry key name for the product that must be uninstalled. This is the registry key under Software\Microsoft\Windows\CurrentVersion\Uninstall that contains the uninstallation information for the product that you want to uninstall.
Tip: To uninstall a previous version of the current product, enter <ProductCode> in this field.
Enter additional arguments for the uninstaller, if any. Be sure to enclose any arguments that contain (or might expand to contain) spaces in quotes, for example "argument with spaces" or "<INSTALLDIR>".
Any arguments that you enter in this field are added to the existing uninstaller arguments taken from QuietUninstallString or UninstallString. This field is meant in particular to provide the correct arguments for a quiet uninstallation; in fact, if you provide any arguments in this field, InstallMate assumes that the uninstaller will be able to run in silent mode (see Uninstall type above).
Tip: You do not have to specify additional "silent mode" arguments for the following uninstallers:
Check this box to ask the user for permission before uninstalling the product; clear it to perform the uninstallation without confirmation. This option is ignored if the installer is running in silent mode (/q command line option; TsuQuiet > 0).
If checked, the installer will display Message #00268 as the confirmation prompt. If the user declines the uninstallation, the installation fails.
Select the action's execution mode from the drop-down list. The following choices are available:
|Not in silent mode||Check this box to skip the action if the installer is running in silent mode (/q command line option; TsuQuiet > 0); clear it to run the action in all modes.|
Select the desired visibility of the uninstaller from the drop-down list. The following choices are available:
Note: If the uninstaller runs in silent mode, this option may or may not have effect, depending on the uninstaller's implementation.
|Hide installer while
Check this box to hide the installer's main window while the action runs; clear the box to keep the installer's window visible.
Note: This option only has effect if the action runs synchronously, i.e., with the Time out option selected. During asynchronous actions, the installer remains visible.
Check this box and enter the time-out period in seconds to execute the action synchronously; clear it to execute the action asynchronously. If the action is executed synchronously, the installer will wait for it to complete; for an asynchronous action, the installer starts the action and then immediately continues.
Note: If the time-out period expires before the uninstaller terminates, the installer continues with its next action. However, the uninstaller itself is not terminated; it will remain active in the background until it terminates of itself or is forcefully terminated by the user or the system.
|Process 2||Enter the name of a secondary process to wait for, or leave empty to wait only for the uninstaller process. This option only has effect if Time out is checked. It is useful if the uninstaller starts a secondary program that must complete before the installer continues.|
Select the exit code handling from the drop-down list. The following choices are available:
The effectiveness of this option depends on the way the uninstaller is programmed. It is customary that successful completion of a program is indicated by an exit code of zero, and failure by a nonzero exit code. (This is how InstallMate uninstallers behave, for example.) However, not all programs comply with this convention. Furthermore, the Uninstall Product action itself may set a nonzero exit code if it cannot start the uninstaller or if the time-out period expires before the uninstaller terminates (see Exit codes).
Before you use the Exit code option, we recommend that you convince yourself that the uninstaller in question returns an appropriate exit code. If you want to use the uninstaller's exit code to terminate the installation or control the execution of subsequent actions, we suggest that you set the Exit code option to Ignore and use one of the following alternative approaches:
Enter the conditional expression that determines if the action will be executed, or leave empty for unconditional execution.
Important: If you use the Uninstall Product action to uninstall a previous version of the current product, then you should set Condition to NOT Installed. This ensures that the uninstallation only takes place during the first installation of the new version and not each time the installer runs for a "Change" or "Repair" installation.
|Disabled||Check this box to disable the action. A disabled action is not included in the installer and not checked during the build. You can use this option to remove actions temporarily from your installer without permanently deleting them. Disabled actions are shown with a grayed-out icon.|
|Platforms...||Click this button to open the Select Installation Platforms dialog box that allows you to select the Windows versions on which the action must be executed. This platform selection acts as an additional condition for the action.|