Wilfred Tang
Wilfred Tang

Reputation: 31

How can I get a Wix CustomAction to print a custom error message if it fails?

How can I get a Wix CustomAction to print a specific error message of my choosing if it fails (rather than a generic error message)?

<CustomAction Id="XXX" Directory="INSTALLFOLDER" ExeCommand="SomeCommand" Return="check" Execute="deferred"/>

Thanks.

Upvotes: 3

Views: 2253

Answers (2)

PhilDW
PhilDW

Reputation: 20800

This is a little confusing because you have an exe custom action, so why can't the program display its actual error message? If the exe doesn't do that, it's not easy to get a meaningful message beyond "the exe failed" unless the exe has a number of exit codes that tell you exactly what happened. So your message is just going to be " failed" with little other information.

If this is your code, and you want to provide a specific error message that describes the error exactly, I'd encourage use of a Dll call, either C/C++ or managed code C# with DTF. Then you can use the Win32 API MsiProcessMessage() and equivalents such as session.message in the C#/DTF world. It has the advantages of knowing when it's a silent install (and not displaying anything), ensuring the message goes on top of the current dialog (probably a progress dialog) and putting the message in the MSI log if you are creating one. All of this obviously assumes that your code is thorough enough to say exactly what failed and why, so that the error message is meaningful.

Upvotes: 2

Erti-Chris Eelmaa
Erti-Chris Eelmaa

Reputation: 26348

You can create a new custom action what does whatever you need it to do. That includes, running your command(s) and logging exactly the bits and pieces what you want, with your own format.

http://blogs.msdn.com/b/jschaffe/archive/2012/10/23/creating-wix-custom-actions-in-c-and-passing-parameters.aspx - Creating WiX custom action.

Upvotes: 0

Related Questions