Search code examples
installshieldinstallscript

how to know whether upgrading, repairing or uninstalling in installscript


I'm trying to write some InstallScript code in Basic MSI project. I would like to know how to determine whether an install is Upgrading or Repairing or Uninstalling.

None of these works in InstallScript -

 REMOVE~="ALL"
 NOT Installed
 REINSTALL<>""
 PATCH<>""
 REMOVEALLMODE

I found this blog and that MAINTENANCE flag works. But it can only determine whether it's Initial Install or Not. Always "TRUE" in Upgrade, Repair and Uninstall.

Any help is appreciated.


Solution

  • The example strings you posted are all examples of Windows Installer Conditions. You can't just cut and paste those into an InstallScript if. Instead you have to call MsiEvaluateCondition to have Windows Installer process them.

    // Note that MSICONDITION_TRUE is 1; I forgot to test whether it's defined
    if MSICONDITION_TRUE = MsiEvaluateCondition(hMSI, "Not Installed") then
        MessageBox("First-time installation", INFORMATION;
    endif;
    

    Note that this only applies in MSI-based installations. For a pure InstallScript project, the Windows Installer APIs are largely unavailable or unusable, and you should instead place code in the proper event handler (such as OnFirstUIBefore).