cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
calvin940
Level 3

Rollback Custom Action not being executed

I have searched the forums and google to no avail so I am asking the question in here.

I have a custom action currently that is commit execution. It creates a file on the file system to identify that the installation was successful by creating a test file with the word success. (This file gets picked up by a different process so we need to store this as part of this installation process for upgrades etc).

This works fine.

However, I wanted a rollback custom action that writes a different file with the word "Failed" in it. I created a custom action, labelled it Rollback Execution, put just before the InstallFinalize, but it never gets called on rollback (I embed an error to force a rollback for testing purposes and it doesn't get called).

I made a separate rollback custom action that just pops up a message box and put it in the same place instead. It doesn't get executed.

I have looked at the log for the install and am trying to figure out how to tell an actual qualified rollback happens. I know that my installer doesn't make the changes to the filesystem so I know the installer is failing properly, but for some reason it just never seems to execute the rollback custom action.

Any help is appreciated.

Thanks
Labels (1)
0 Kudos
(8) Replies
RobertDickau
Flexera Alumni

You'll want to schedule the rollback action before the deferred action it rolls back. (Buried in the MSI help topic "Rollback Custom Actions", among other places.)
0 Kudos
calvin940
Level 3

RobertDickau wrote:
You'll want to schedule the rollback action before the deferred action it rolls back. (Buried in the MSI help topic "Rollback Custom Actions", among other places.)


It is located there. I guess I'll elaborate.

I have a Custom Action called:

WriteSuccessResponseFile

That executes an Installscript function that writes a file with the word success in it. That is just before InstallFinalize. It is configured as Commit Execution.

I have another custom action called:

WriteFailedResponseFile

That executes an Installscript function that writes a file with the word failed in it. That is just before the WriteSuccessResponseFile. It is configured as Rollback Execution.

The WriteSuccessResponseFile custom action will write the file I want during a successful install. However, the WriteFailedResponseFile custom action does not execute when I force the installer to fail (either through cancelling in the midst of an install or forcing it to fail via an error custom action).

I even made a very simple Rollback custom action that simply displays a messagebox should a rollback occur. No messagebox appears.
0 Kudos
RobertDickau
Flexera Alumni

When you force rollback, are you forcing it in deferred mode after WriteFailedResponseFile but before InstallFinalize? An immediate action failing won't trigger rollback at all, and a failing deferred action won't trigger any rollback actions that follow it in the sequences.

For example, does anything change if you put the rollback action right after InstallInitialize?
0 Kudos
calvin940
Level 3

RobertDickau wrote:
When you force rollback, are you forcing it in deferred mode after WriteFailedResponseFile but before InstallFinalize? An immediate action failing won't trigger rollback at all, and a failing deferred action won't trigger any rollback actions that follow it in the sequences.

For example, does anything change if you put the rollback action right after InstallInitialize?


.
.
.
InstallInitialize
.
.
.
WriteFailedResponseFile (Rollback Execution)
WriteSuccessResponseFile (Commit Execution)
FailInstall (immediate Execution)
InstallFinalize
.
.
.



I also tried

.
.
InstallInitialize
RollbackActionTest (Rollback Execution - installscript simply displays mbox)
.
.
.
FailInstall (immediate Execution)
InstallFinalize
.
.
.

I have also removed my FailInstall custom action from my installer and simply hit cancel during install. That cancel should also trigger a rollback but my rollback custom action does not execute in that case either. What am I missing here?

Thanks
0 Kudos
calvin940
Level 3

RobertDickau wrote:
When you force rollback, are you forcing it in deferred mode after WriteFailedResponseFile but before InstallFinalize? An immediate action failing won't trigger rollback at all, and a failing deferred action won't trigger any rollback actions that follow it in the sequences.

For example, does anything change if you put the rollback action right after InstallInitialize?


So that line just sunk in after I posted the previous message. I changed my ForceFail Custom action to be a deferred custom action. That now does cause a true rollback AND my rollback custom actions are now being executed. Thanks for that. I have one final question, however. Why doesn't a user cancellation also cause a rollback? I cancelled the installer in the middle of the the install process (after the Install button is clicked - isn't that the execution phase?).

If a rollback is not triggered upon user cancellation, what is? How can I programmatically tell if the user has cancelled the installation so I can write my file?

Thanks
0 Kudos
RobertDickau
Flexera Alumni

The idea is that neither the UI sequence nor the Execute sequence's immediate mode should make system changes---they're just gathering info and making a to-do list---so there's nothing to roll back.
0 Kudos
calvin940
Level 3

Thanks for your help. It does make sense in the way it works once I understood the script execution. The only other question I have is how I will be able to programmatically understand that the installation was cancelled and then write a file to the filesystem after that has happened.

Any help would be appreciated.
0 Kudos
RobertDickau
Flexera Alumni

Please see the MSI help library topic "InstallExecuteSequence Table": I think you can put an action in that table with sequence number -2 to detect user cancellation.
0 Kudos