I have a pretty lengthy CustomAction in a wix installer, and I want to be able to change the 'Status: ...' text while the operation runs, to see that there is progress and update on its internal status. I know how to set the progresstext of a custom action - but what I want is to dynamically change the progress text during the run of the custom action.
3 Answers
Deferred Custom Actions can call the MsiProcessMessage function. You can then use INSTALLMESSAGE_ACTIONSTART, INSTALLMESSAGE_ACTIONDATA and INSTALLMESSAGE_PROGRESS to publish messages up to the UI.
Another possibility would be to break your custom action up into smaller custom actions and use the ProgressText (ActionText table) to describe different phases of installation. ( Make each CA have a single responsibility. )
Sometimes when a CA does too much work it's hard to plan rollbacks correctly.
Obtaining Context Information for Deferred Execution Custom Actions
Using C#/DTF it looks something like:
using (Record record = new Record(0))
{
record.SetString(0, "foo");
session.Message(InstallMessage.ActionData, record);
}
The using statement disposes the record to free up the underlying MSI handles. The number of fields in the record and how you set the data is going to depend on the template defined in the ActionText table.
Chris has correctly explained how to send the message to ActionData
from your CA, but if you are using InstallShield, make sure you create a label on the SetupProgress
dialog and subscribe the ActionData
text event to it. Simply, creating an ActionText
event for a label is not enough as it will only display the CA description you create in the ActionText Table.