Extract Substring from Product Version - Advanced Installer Community
SimLoe
Posts: 69
Joined: Thu Mar 12, 2020 11:37 am

Extract Substring from Product Version

Our software is using a four part version (e.g. 9.0.0.12865) where the last part (12865) only reflects the Changeset Number. I have been using the Version extraction in the Product Details page to read this version from an exe file. This has been working fine, but lead to the undesired behavior described here: viewtopic.php?t=26110: I have several entries in the "Add / Remove Products" list.
This is why, I would like to change the version number to only the first three parts (e.g. 9.0.0).

Is there a simple and smart way to do that (just trim the ".12865")? I know it would probably work with a custom powershell script, but I don't consider this smooth. Is there a simple way to extract the substring of the version?

Best regards,

Simon
Catalin
Posts: 7852
Joined: Wed Jun 13, 2018 7:49 am

Re: Extract Substring from Product Version

Hello Simon,

By default, the 4th field of the ProductVersion is ignored.

This is the default behavior offered by the Windows Installer technology. For more information about this, please refer to the "ProductVersion property" article.

This will indeed lead to the problem you mentioned (multiple entries of the same application).

However, it is still possible to remove the older versions (even when using the fourth field). We start here from the premise that your fourth field is only going to increase (never decrease). In order for your setup to take the fourth field into consideration, please proceed as it follows:
  • Go to the Upgrades page and enable the "Customize Advanced Installer upgrade rules" option;
  • Double-click on the Advanced Installer rule that is related to the [OLDPRODUCTS] property;
  • In the Product Info tab, enable the "Include maximum version in range" option and click OK;

Please note that you need to generate manually a new ProductCode in the "Product IDs" Tab from the "Product Details" page.

Hope this helps.

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
SimLoe
Posts: 69
Joined: Thu Mar 12, 2020 11:37 am

Re: Extract Substring from Product Version

Hello Catalin,

after having changed the upgrade rule, I encounter the following problem:

I can install one package normally on a virtual machine (e.g. version 9.0.0.12000)
When I try to install a newer version (e.g. version 9.0.0.12005), I always get an error that the first custom action after the "Install Finalize" execution stage fails and thus the setup does not continue. I tried it with different custom actions, but it always behaves the same: I can see in the Windows Event Log that there was a problem executing this action, but I don't know why it only happens when I install a newer version and not when I install it for the first time.
When I try to run the content of the custom action manually after the setup, everything works fine.

I am using the following settings:
service.PNG
service.PNG (62.36 KiB) Viewed 5024 times
Best regards,

Simon
Catalin
Posts: 7852
Joined: Wed Jun 13, 2018 7:49 am

Re: Extract Substring from Product Version

Hello Simon,

This most probably happens because of the installation condition.

Under "Execution Stage Condition", I can see that your custom action is scheduled to run when your product is "Replaced by a new version".

That option basically means that, after the new setup uninstalls the old one, it will try to execute the custom action and since all the files were removed, the custom action will fail. You can think of it like this:

- v1.0 is installed

- v2.0 is deployed

- v2.0 first uninstalls v1.0. During the v1.0 uninstallation, it gets to the "InstallFinalize" point and it then tries to execute the custom action. Since it previously just removed all the files, the custom action will fail.

The solution to this would be to remove that option and only let the "Upgrade" option. The "Upgrade" option means that the custom action will be executed after v2.0 is installed => the file will exist on the machine, therefore the custom action should succeed.

Hope this helps.

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
SimLoe
Posts: 69
Joined: Thu Mar 12, 2020 11:37 am

Re: Extract Substring from Product Version

Hi Catalin,

indeed it worked!

Thank you very much!
Catalin
Posts: 7852
Joined: Wed Jun 13, 2018 7:49 am

Re: Extract Substring from Product Version

You are always welcome, Simon!

I am glad everything works as expected now.

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”