Predefined Execution Conditions: Use with Caution - Advanced Installer Community

We’re moving our forums to a new platform.

You can still browse and search existing topics, but you can no longer create new topics or post replies.

For questions, technical issues, or feature requests, please don’t hesitate to contact our support team at support@advancedinstaller.com.

Thank you for your understanding!

bjk68
Posts: 55
Joined: Tue Dec 01, 2009 12:45 pm

Predefined Execution Conditions: Use with Caution

There are some Predefined Execution Conditions, that not always act the way you would expect.

Be aware that during an upgrade the first Sequence Steps are from the new version. At a certain point, the sequence is transferred to the old version MSI for the uninstall. After that the sequence is transferred back to the new version for the install.

Predefined Execution Condition: Test if it is the first installation: Not Installed
  • At the CostFinalize step of the new version during an upgrade, the Installed property is empty. :o So your action could unexpectedly run during an upgrade.
Predefined Execution Condition: Test if uninstall is in progress: REMOVE="ALL"
  • When you uninstall by double clicking the MSI, choosing "Remove", the REMOVE property has the value "MainFeature" at the "Begin" step of the Install Sequence. :o Your action could fail to run, even when an uninstall is in progress. This happens because the value of the property REMOVE is set to "ALL" after the standard action "InstallValidate" and not from the first moment you start the MSI.
Predefined Execution Condition: Test if the application is uninstalled, but not by an upgrade: REMOVE="ALL" AND (NOT UPGRADINGPRODUCTCODE)
  • When you uninstall by double clicking the MSI, choosing "Remove", the REMOVE property has the value "MainFeature" at the "Begin" step of the Install Sequence. :o Your action could fail to run if the application is uninstalled when you attach your Custom Action to an Install Sequence step too early in the sequence. This happens because the value of the property REMOVE is set to "ALL" after the standard action "InstallValidate" and not from the first moment you start the MSI.
Remark:
Edited after support made things more clear.
Thanks Bogdan and Cosmin for your support in this complex matter.
Last edited by bjk68 on Thu Feb 04, 2010 6:16 pm, edited 3 times in total.
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Re: Predefined Execution Conditions: Use with Caution

Hi,
Predefined Execution Condition: Test if it is the first installation: Not InstalledPredefined Execution Condition: Test if it is the first installation: Not Installed
During the uninstall-phase of an upgrade, the Installed property is empty. So your action could unexpectedly run during the uninstall phase of an upgrade.
Please note that action conditions are evaluated when the install process script is created (during the Immediate phase), so the property is evaluated correctly during an uninstall, even when used for deferred actions. However, deferred actions cannot access installer properties, so any property will be empty when accessed from a deferred custom action.
When you uninstall by double clicking the MSI, choosing "Remove", the REMOVE property has the value "MainFeature" at the "Begin" step of the Install Sequence. Your action could fail to run, even when an uninstall is in progress. This happens because the value of the property REMOVE is set to "ALL" after the standard action "InstallValidate" and not from the first moment you start the MSI.
This is the normal Windows Installer behavior. If you want to execute actions during an uninstall before "InstallValidate" you can use other types of conditions. For example, you can check if the "REMOVE" property is set.
The REMOVE property is empty during the uninstall phase of an upgrade. During the uninstall phase of an upgrade your action would fail to run.
This property is set when action conditions are evaluated, so an action which uses it will work correctly.
The UPGRADINGPRODUCTCODE property is empty during the uninstall phase of an upgrade. This property only has a value during the install phase of an upgrade. Your action would fail to run during the uninstall phase of an upgrade.
This property is set for a package which is being uninstalled by an upgrade and it is evaluated correctly by this uninstall process.

I think you used deferred custom actions to show the property values, so all properties appeared empty. Please note that only Immediate actions have access to installer properties.

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
bjk68
Posts: 55
Joined: Tue Dec 01, 2009 12:45 pm

Re: Predefined Execution Conditions: Use with Caution

cosmin wrote:I think you used deferred custom actions to show the property values, so all properties appeared empty. Please note that only Immediate actions have access to installer properties.
I used a "Script Inline" Custom Action with Synchronous Immediate execution. The VBScript I used is as follows:

Code: Select all

MsgBox "ProductVersion: " & Session.Property("ProductVersion") & " Installed: " & Session.Property("Installed") & " UPGRADINGPRODUCTCODE: " & Session.Property("UPGRADINGPRODUCTCODE") & " REMOVE: " & Session.Property("REMOVE")
I examined the values of these properties for the Begin step and for the CostFinalize step.

Without the version number in de MsgBox it looks like the properties are empty during the uninstall phase of an upgrade, because the CostFinalize step of the new version is executed before the CostFinalize of the old version. But support has made it clear to me that the order of the executed steps is not as straightforward as I thought.

During an upgrade the first steps in the sequence (e.g. CostFinalize) are from the new version (initialisation), than you see sequence steps from the old version (uninstall), and than the sequence continues in the new version (install).

Remark:
Edited after support made things more clear.
It appeared that the CostFinalize step of the new version (install) was executed before the CostFinalize step of the old version (uninstall).
The addition of the ProductVersion in the MessageBox clarified this behaviour during the upgrade.
Last edited by bjk68 on Thu Feb 04, 2010 6:22 pm, edited 3 times in total.
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Re: Predefined Execution Conditions: Use with Caution

Hi,

I tested this scenario using the code you provided and the property values are shown correctly when the old version is uninstalled by an upgrade. I'm not sure why your package doesn't show the property values. Can you please send us the .AIP (project) files you are using to support at advancedinstaller dot com so we can investigate them?

Regars,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
bjk68
Posts: 55
Joined: Tue Dec 01, 2009 12:45 pm

Re: Predefined Execution Conditions: Use with Caution

Thanks Bogdan and Cosmin for your support. You clarified some unexpected results, and I edited the corresponding forum posts.

However, some issues remain. Some Predefined Execution Conditions can still lead to unexpected results. See my edited first post in this thread. But I understood that you will update the User Guide to make it more clear how to use the Execution Conditions and how to select the correct Sequence Step for your Custom Actions.
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Re: Predefined Execution Conditions: Use with Caution

Hi,
At the CostFinalize step of the new version during an upgrade, the Installed property is empty.
This is because the "Installed" property refers to a package, not to a product. Different product versions use different packages. To detect a first time installation which doesn't involve an upgrade you can use the OLDPRODUCTS property:

Code: Select all

(NOT Installed) AND (NOT OLDPRODUCTS)
Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”