cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
loralynne
Level 6

Delete generated files during rollback

I have a basic MSI that installs and starts a service, which generates files and folders in the install directory. I have a deferred custom action with synchronous return processing (checking exit code) that checks for the existence of one of these files. If this file doesn't exit, the custom action will return an error, and the installation will roll back.

The files and folders that got generated by the service also need to be deleted during rollback, so I followed the steps here to do that: http://helpnet.installshield.com/installshield21helplib/helplibrary/AccessingProps-DeferredCAs.htm. I?m trying to get the value of INSTALLDIR in the below MSI DLL custom action, but it doesn't seem to be working because when I do an MsiGetProperty of INSTALLDIR and display a message box with this value, it's empty.

Here's what I did:

INSTALLDIR is listed in SecureCustomProperties

Set Property Action
Custom Action Name: SetCAData
Property: RemoveGeneratedFiles
Property Value: [INSTALLDIR]
Return Processing: Synchronous (Check exit code)
Execution Scheduling: Always Execute
Install Execute Sequence: After InstallInitialize

MSI DLL Custom Action
Custom Action Name: RemoveGeneratedFiles
Function Name: RemoveGeneratedFiles
Return Processing: Synchronous (Check exit code)
In-Script Execution: Rollback Execution in System Context
Install Execute Sequence: After SetCAData

Here are some snippets from the install log:
Rollback: RemoveGeneratedFiles
MSI (s) (F0:54) [07:12:01:514]: Executing op: ActionStart(Name=RemoveGeneratedFiles,,)
MSI (s) (F0:54) [07:12:01:514]: Executing op: CustomActionRollback(Action=RemoveGeneratedFiles,ActionType=3329,Source=BinaryData,Target=RemoveGeneratedFiles,CustomActionData=C:\Program Files\Your Compay Name\rollback\)
...
Property(S): INSTALLDIR = C:\Program Files\Your Compay Name\rollback\

Does anyone have any advice on how to remove these generated files during rollback?

Thanks in advance.

Labels (1)
0 Kudos
(2) Replies
dan_galender
Level 10

You don't state, but is SetCAData an immediate custom action? It should be. While it's not necessary to do, a good practice would be to call this action SetRemoveGeneratedFiles instead of SetCAData. This would be very useful if you were setting CustomActionData for multiple deferred custom actions. This way it would be clear which action's property was being set by this action.

Try putting that action prior to InstallInitialize.

In RemoveGeneratedFiles, the property you should be referencing in MsiGetProperty is "CustomActionData" (not INSTALLDIR). The only properties that are available to deferred custom actions are "ProductCode", "UserSID", and "CustomActionData". Attempts to retrieve any other properties will return a null string.
0 Kudos
loralynne
Level 6

Thank you for your reply, Dale. Yes, SetCAData is an immediate custom action. And you're right -- I was referencing INSTALLDIR instead of CustomActionData...dumb mistake.

Thanks again!
0 Kudos