View Full Version : Deferred Custom Action Conditioning

05-27-2004, 10:06 AM
I am currently using a custom action that will trigger a rollback if a certain executable that is run returns an error. This custom action that runs the executable is a vbscript that catches the return value and sets a property depending on the return value.

This custom action needs to run as deferred because if it is run with immediate execution, the custom action will try to run the exe before it is copied to the system. However, I also have a Type 19 custom aciton called AbortInstall that will abort the install if the executable returns an error. I need to condition AbortInstall, but I'm not sure how to do it. I was going to set a property if the executable returned an error and have the AbortInstall custom action be conditioned on that property, but when you are running custom actions as deferred, you lose access to all public properties.

I was going to try and run the executable as immediate after InstallFinalize, but then it won't rollback because it is after InstallFinalize. Is there any way to condition AbortInstall based on the actions of the custom action that is running the executable? Or is there a way to make this all work without having to run the custom actions as deferred?

05-27-2004, 12:04 PM
Look into running your custom action as rollback one, type 1281.


05-27-2004, 12:50 PM
Thanks for the suggestion. However, I still have to condition that custom action based on what the executable returns in the previous custom action. If I'm running these guys deferred, I won't have anything to use as conditions.

The only reason I am running these CAs as deferred is because the CA I have to run the executable needs the path of the executable. Originally, I ran the CA with immediate execution, which gave me access to INSTALLDIR, but the file was not yet on the system, so even though it had the path to the exe, it couldn't run it.

Instead, I used a component to store INSTALLDIR in the registry. Then the CA that runs the exe can run deferred and just read the INSTALLDIR out of the registry since it doesn't have direct access to the property INSTALLDIR. But after that, I get stuck, because I can't condition the rollback CA to use a property, because with deferred CAs, the properties aren't available.

So that is the full story of my dilemma.

05-27-2004, 01:09 PM
Properties can be passed to deferred custom actions by using the CustomActionData property. This is explained in more detail here: Obtaining Context Information (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/msi/setup/obtaining_context_information_for_deferred_execution_custom_actions.asp). Since you are calling a VB custom action to run the exe, you can have it return the error ERROR_INSTAL_FAILURE which will trigger the rollback. No condition is required on the rollback custom action. It just needs to be placed before the one that executes the exe.