Setup Commands Preceding Apply Uninstall
InstallAware, unlike most other installation authoring toolkits, offers a unified, single script which gives you complete control over the entire installation process, including the uninstallation. However, because of design limitations in Windows Installer, you need to refrain from using new Windows Installer commands before an Apply Uninstall command. Doing so can break the integrity of your setup database and cause uninstalls to fail.
This topic only applies to the
engine and not the . The precautions and workarounds described in this topic are not needed with the .The Install - Uninstall Cycle
The points below explain the design limitation in Windows Installer.
- The first time you are installing, your script queues several Windows Installer commands as required by your application. These changes are then executed when the Apply Install command is called from your script. At that point, InstallAware invokes the Windows Installer service and completes the installation.
- When the setup is run again (in maintenance mode), and a repair/modify action is chosen, your script again queues the pertaining Windows Installer commands, and then calls Apply Install once again to update the system. If the set of installed features changed between the original and maintenance installs, Windows Installer is intelligent enough to reflect those changes to the system: Windows Installer commands which do not execute as a result of changed feature sets are automatically undone (example: Install Files commands belonging to unselected features are undone, since those commands did not execute in this run).
- To achieve the above flexibility, Windows Installer keeps its own internal record of which actions executed during the last run.
- When Apply Uninstall is called, all the Windows Installer commands from the last run will be undone, effectively uninstalling the application.
- If however, immediately before executing the Apply Uninstall command, new Windows Installer commands are queued, this will destroy Windows Installer's internal records of the last standing actions. The net result will be that all installed files and registry settings belonging to your application will be orphaned on the system, without actually being removed.
Workarounds
If you simply must use Windows Installer commands before uninstalling, you may do so by following the exact procedure below.
- For your new commands to work as expected, you need to call Apply Install first.
- Keep in mind this will undo actions which executed during the previous run, and may cause a premature removal of some files/registry entries.
- After this step is complete, call Apply Uninstall normally to undo the changes you just made and remove all traces of your application from the system.
Keep in mind that you may use non-Windows Installer commands freely at any point in your script, including immediately above the Apply Uninstall command. The Call DLL Function command especially provides a lot of flexibility in being able to invoke virtually all of the Windows API directly from your setup.
New Windows Installer Commands May Not Be Necessary
Windows Installer already has mechanisms to work around this limitation. In particular, if you wish to delete files created by your application after it was installed, it may seem that new Delete Files commands are required right above the Apply Uninstall command. However this is not the case. The Delete Files command has an option which explicitly specifies when files are to be deleted - while installing, while uninstalling, or both.
To delete files created by your application after it was installed:
- Call the Delete Files command as part of your main installation routine (the install/maintain block), and not the uninstallation routine.
- In the options for the Delete Files command, indicate that the deletion is to occur during an uninstall.
- Windows Installer adds this command to its internal record, and will remove the specified files when Apply Uninstall is called at a later time.
Unfortunately, Windows Installer does not provide a mechanism to remove registry keys that are not created explicity during the installation. However, InstallAware accomodates this need by providing a non-Windows Installer command to facilitate this task.
To delete registry keys created by your application after it was installed:
- Call the Delete Registry command as part of your uninstallation routine.
- This is not a Windows Installer command command, so it is safe to call right above the Apply Uninstall command.