Answer

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 :

  • Create a vbscript file with any editor, like Notepad.
  • 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
  • Attach the vbscript to your project as "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".
  • Use the Custom Action in the project as a "DoAction" Event with the "WriteToLog" Argument.
  • Run the installation package with logging enabled.

NoteFor more information on how to enable logging see: Windows Installer Logging

  • The events selected by your custom action will appear in the installation log.