简体   繁体   中英

WIX MajorUpgrade and return code

I am writing an installer that also contains MSI package built using WIX. I check the return code after running msiexec and skip some error codes. For example user should't receive error when return code is 1638 (product has already installed)

But when the older version of product was installed the return code is 1603 (unknown error). I also want to skip this situation (user already get newer version)

Wix code is

<Upgrade Id="<GUID>">
    <UpgradeVersion Minimum="$(var.product_version)" OnlyDetect="yes" Property="NEWERFOUND" />
    <UpgradeVersion Minimum="0.1.0" IncludeMinimum="yes" Maximum="$(var.product_version)" IncludeMaximum="no" Property="SELFFOUND" />
</Upgrade>

<MajorUpgrade DowngradeErrorMessage=You have installed newer version $(var.product_name)." />

The question is how I can return another code than 1603 when SELFFOUND or NEWERFOUND properties are activated

Update: I didn't want to influence the return code, I want to get appropriate code instead the general fatal error

You can't control the return code of msiexec.exe . Its return codes are documented and the list is comprehensive. The service determines the exit code based on the status of installation.

Update: The only thing I can suggest is to use database functions directly:

  1. MsiOpenPackage , and
  2. MsiDoAction("FindRelatedProducts") to run FindRelatedProducts action which will evaluate SELFFOUND and NEWERFOUND properties by processing Upgrade table .
  3. Then analyze the properties with MsiGetProperty .
  4. Close the package with MsiCloseHandle .

Using the obtained values of SELFFOUND and NEWERFOUND , you can decide whether you need to install the product or not. If yes, you can run msiexec.exe or use MsiInstallProduct .

Disclamer: I have never tried to do anything like this, and I am not sure it will work. It should, yet it does not look easy.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM