How can I tell if Windows Installer is updating, not installing for the first time?

I have an installation that updates the previous version of the application if it comes out. I want to skip certain actions when the installation is in upgrade mode. How to determine if installation is in upgrade mode compared to installation mode for the first time?

I use the Wise Installer, but I don’t think it matters. I assume that the Windows installer has a property set when the installer is in update mode. I just can't find it. If the property exists, I assume that I can use it in a conditional expression.

+4
source share
3 answers

Can you clarify what tools you use to create this installer?

I am using Windows Installer XML ( WIX ). On WIX, you can do something like this:

<!-- Property definitions --> <?define SkuName = "MyCoolApp"?> <?define ProductName="My Cool Application"?> <?define Manufacturer="Acme Inc."?> <?define Copyright="Copyright Β© Acme Inc. All rights reserved."?> <?define ProductVersion="1.1.0.0"?> <?define RTMProductVersion="1.0.0.0" ?> <?define UpgradeCode="{EF9D543D-9BDA-47F9-A6B4-D1845A2EBD49}"?> <?define ProductCode="{27EA5747-9CE3-3F83-96C3-B2F5212CD1A6}"?> <?define Language="1033"?> <?define CodePage="1252"?> <?define InstallerVersion="200"?> 

Define update options:

 <Upgrade Id="$(var.UpgradeCode)"> <UpgradeVersion Minimum="$(var.ProductVersion)" IncludeMinimum="no" OnlyDetect="yes" Language="$(var.Language)" Property="NEWPRODUCTFOUND" /> <UpgradeVersion Minimum="$(var.RTMProductVersion)" IncludeMinimum="yes" Maximum="$(var.ProductVersion)" IgnoreRemoveFailure="no" IncludeMaximum="no" Language="$(var.Language)" Property="OLDIEFOUND" /> </Upgrade> 

Then you can use the OLDIEFOUND and NEWPRODUCTFOUND , depending on what you want to do:

 <!-- Define custom actions --> <CustomAction Id="ActivateProduct" Directory='MyCoolAppFolder' ExeCommand='"[MyCoolAppFolder]activateme.exe"' Return='asyncNoWait' Execute='deferred'/> <CustomAction Id="NoUpgrade4U" Error="A newer version of MyCoolApp is already installed."/> 

The above actions must be defined in InstallExcecuteSequence

 <InstallExecuteSequence> <Custom Action="NoUpgrade4U" After="FindRelatedProducts">NEWPRODUCTFOUND</Custom> <Custom Action="ActivateProduct" OnExit='success'>NOT OLDIEFOUND</Custom> </InstallExecuteSequence> 
+2
source

There is an MSI property called Installed , which will be true if the product is installed for each computer or for the current user. You can use it in conditional boolean operators.

You can also check this other installation status for MSI properties if one of them works better. I have never used Wise, but I assume there is a way to get these properties.

+1
source

I'm not sure I understood your question.
If you type the installation script yourself, the best way on Windows is to check the registry keys that such a program usually creates. Unlike the installation directory (and entries in the Start menu, etc.), It is an invariant. One of these keys may even be the software version number to check if the user is trying to install the old version (or know whether to delete some files, etc.).

-1
source

Source: https://habr.com/ru/post/1277271/


All Articles