Logging an event using a vbscript custom action
In case an event is needed to appear in the log file, this can be done by using a Custom Action. For this we will use a custom vbscript.
In order to do this, the following steps must be taken :
1. Create a vbscript file with any editor,
2. In the newly created file, copy the following code:
Function WriteToLog Const MsgType = &H04000000 Set rec = Installer.CreateRecord(1) rec.StringData(1) = CStr(Session.Property("APPDIR")) 'rec.StringData(1) = CStr("Any type of message can be wrote here") Session.Message MsgType, rec WriteToLog = 0 End Function
3. Attach the vbscript file to your project
as a new attached custom action. To do this, go to Custom Actions and
select "Launch attached file" without sequence from the "Add Custom
Actions" pane. Write "WriteToLog" without the quotes in the "Function
Name" field. Rename the newly added Custom Action to "Event_Logging".
4. Trigger the custom action in the project as an "Execute custom action" published event, from a button you choose on the MSI dialogs, with the argument set to: "WriteToLog".
5. Run the installation package with logging enabled.
6. The messages written by your custom action should appear in the installation log.