cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
thedude458
Level 2

Terminating an install from the UI and EXECUTE sequences (Basic MSI)

I have an installer that is using a custom action to check if a certain application is installed, and setting a property value to 1 (if the product is installed) or 0 (if the product is not installed).

What I would like to do, is both from the UI and EXECUTE sequences, display an error message and terminate the installation if the value of this property is 0.

I figured that this was a good time to use an "Error" custom action, but that didn't seem to do the trick. What I noticed is that when I executed an error custom action from a dialog in the UI sequence (using the DoAction control event), that it simply aborted the UI sequence and proceeded to the EXECUTE sequence rather than aborting the entire installation, which is really what I want. I was able to work around this by using a VBScript custom action to display a message box with the error message, and then using the EndDialog control event to abort the install. Is there a simpler/better way to display an error message and terminate the install from the UI sequence, since the error custom action doesn't seem to do the trick?

When I executed the Error custom action from the EXECUTE sequence, it did abort the installation, however the Installer displayed the dialog that showed that the installation was successful, which is not the case, since it was aborted due to an error condition. I definitely don't want a user to think the install was successful when it was not. How can you both display an error message and ensure that the installer shows the appropriate dialog, indicating an unsuccessful install, during the EXECUTE sequence?
Labels (1)
0 Kudos
(2) Replies
KathyMorey
Level 10

Try this: if the application is present, set your public property to any value; if it is not present, don't set the property at all. (Make sure it is NOT in the Property Manager.). Then set your type 19 (error) custom action to use the property.

Error custom actions abort the installation if their condition evaluates to true. If your property exists (has a value), the condition will be true and the install will abort. If your property does not exist, the condition will evaluate to false and the type 19 custom action will not fire.

Again, just use the property, don't check for a value in the property. (MYPROP, not MYPROP="1").
0 Kudos
thedude458
Level 2

Thanks for the advice Kathy! I will certainly give that a try in the future.

For anyone else that may come across this post, I was able to eventually resolve this issue by displaying the error message and returning an error/failure status from my custom action, which is written in C# using the DTF API for .NET.

To properly display the error message, since using MessageBox.Show may open the dialog window behind the installer window, take a look at this very helpful thread over at Stackoverflow. To return a failure status with DTF, I just simply returned ActionResult.Failure from my custom action.
0 Kudos