0

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.

  • Are you using an InstallScript project, or InstallScript code in some sort of MSI project (either Basic MSI or InstallScript MSI)? Most of the items you mention are MSI-related, and thus are either irrelevant or take extra steps to use in InstallScript code. – Michael Urman Jan 14 '16 at 13:53
  • @MichaelUrman updated. it's Basic MSI project. – black dragon Jan 15 '16 at 00:49
  • Short answer: call [MsiEvaluateCondition](https://msdn.microsoft.com/en-us/library/aa370104.aspx) (it's available in InstallScript) with those as conditions. – Michael Urman Jan 15 '16 at 13:08
  • It works, finally. Thanks Can you post this again as answer? – black dragon Jan 18 '16 at 05:49

1 Answers1

0

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).

Michael Urman
  • 15,737
  • 2
  • 28
  • 44