Preparing an InstallScript Installation for Uninstallation
InstallShield 2020
Setting up uninstallation functionality is simple, considering the complexity of the operations that result. CreateInstallationInfo (or InstallationInfo) and MaintenanceStart (or DeinstallStart) must be called. In an event-based script, CreateInstallationInfo and MaintenanceStart are called in the default OnMoveData event handler code.
There are other functions that play important roles in setting up uninstallation functionality. For example, all keys created using the RegDBCreateKeyEx function are recorded for uninstallation, unless logging is disabled. Also, if you call the Disable function to disable logging, remember to call Enable to enable the logging again for subsequent actions that must be recorded for uninstallation.
MaintenanceStart (or DeinstallStart) creates the necessary registry key and its necessary values. To create additional registry values under this key, call RegDBSetItem, or for custom values use code like the following:
RegDBSetDefaultRoot( HKEY_USER_SELECTABLE );
RegDBSetKeyValueEx( "Software\\Microsoft\\Windows\\Current Version\\Uninstall\\" + INSTANCE_GUID, "My Custom Value", nType, szValue, nSize);
Note:Uninstallation is available only if the initial installation calls FeatureTransferData or FeatureMoveData. (In an event-based script, the FeatureTransferData function is called automatically.) If your installation installs files by some other means (for example, XCopyFile) and you want to make uninstallation available to your end users, deselect all components and call FeatureTransferData or FeatureMoveData; while this call is executed, you can call SdShowMsg to display a message.
Including Script Code to Be Executed During Uninstallation
Note:If you call DeinstallStart to enable uninstallation, the installation script is not executed during uninstallation. To execute script code during uninstallation, call MaintenanceStart instead. (In an event-based installation, MaintenanceStart is called in the default OnMoveData event handler code.)
Event-Based Scripts
If your script is event-based, the following event handler functions are called during uninstallation:
• | OnBegin |
• | OnMaintUIBefore |
• | OnMoving |
• | <Feature name>Uninstalling (for each installed feature) |
• | <Feature name>Uninstalled (for each installed feature) |
• | OnMoved |
• | OnMaintUIAfter |
• | OnEnd |
The code in these event handler functions (whose default code you can override) is executed during the uninstallation. For instructions on executing certain event handler code only during uninstallation, or only during installation, see Executing Script Code Only During Uninstallation or Only During Installation.
Procedural Scripts
If your script is procedural (that is, uses a program block) and calls MaintenanceStart rather than DeinstallStart to enable uninstallation, the script is executed during uninstallation. For instructions on executing certain script code only during uninstallation, or only during installation, see Executing Script Code Only During Uninstallation or Only During Installation.