vcorazza
Posts: 17
Joined: Wed Dec 06, 2017 3:14 pm

Custom action on error

Wed Dec 18, 2019 12:18 pm

Hi, we have a complex installation project which launches various prerequisites and custom actions.
We need to have a custom action to be launched whenever the installation fails for any reason: I have tried a custom action to be run "During installation rollback", but it seems not to be run, for example neither when a service start fails, nor when another custom action fails.
Is there a way to launch a custom action at any failure?
Thanks

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

Re: Custom action on error

Wed Dec 18, 2019 4:07 pm

Hello,

As you may know, the installation process is basically a sequence of actions. Let's have the following example, so you can better understand what I'm about to say:

Action_Deferred_1

Action_Deferred_2

Action_Deferred_3


Basically, the above actions will be executed in the following order: 1, 2 and 3. If one of the action fails, the rollback action will start from bottom to top. For instance, if Action_Deferred_3 fails, the rollback will look like this:

Undo_Action_Deferred_3

Undo_Action_Deferred_2

Undo_Action_Deferred_1


As you can see, the order is reversed. So basically, if you want to have a custom action that executes on rollback stage, when Action_Deferred_3 fails, this could be the order of your actions:

Action_Deferred_1

Action_Deferred_2

Action_Rollback

Action_Deferred_3


The rollback action must be scheduled prior to the failing action.

Please find attached, for your reference, an .AIP file which you can download and build on your machine. This .AIP file contains a PowerShell custom action that returns an exit code of "3", failing the installation. On rollback, there is a message box custom action that will be spawned.
Rollback action - Sample.aip
(14.17KiB)Downloaded 213 times
Hope this helps.

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

vcorazza
Posts: 17
Joined: Wed Dec 06, 2017 3:14 pm

Re: Custom action on error

Wed Dec 18, 2019 4:26 pm

Thank you very much for your clear and quick response. But, what if the prerequisite that fails is launched, let's say, in the Searches phase (before the Path resolution phase)? Custom actions there do not have the On the During installation rollback option enabled. Or what if a prerequisite fails (either a feature prerequisite or a Pre-install prerequisite)?

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

Re: Custom action on error

Mon Jan 06, 2020 3:14 pm

Hello,

First of all, please accept my apologies for such a delayed reply, but we had some days off here due to holidays and the New Year's, therefore I was not able to answer this thread.

You are always welcome! I'm really glad my explanation helped.

In what regards your question, please keep in mind that the changes on the system are done only during the deferred stage (e.g. files are copied, services are installed, registry entries are configured, etc.), therefore only these actions can have rollback actions, because only for these actions it is necessary to have rollback actions.

By default, immediate actions should not modify anything on the system.

In what regards your prerequisite question, please keep in mind that prerequisites are also installation packages, therefore most of them have rollback actions already incorporated in the setup. For instance, if you want to install .NET Framework as a prerequisite, if the installation fails, the .NET Framework setup itself will do the cleanup (i.e. rollback).

Hope this helps.

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

Return to “Common Problems”