November 27, 2009

How to write into MSI Log File from Custom Actions using Installshield

Writing into MSI Log file from Custom Actions

InstallShield, by default, handles logging the start / end & success or failure of the Custom Action into MSI Log and here is the code snippet, from an InstallShield document, for writing detailed information into MSI Log file from the Custom Actions. The custom action can be written in InstallScript, VBScript or DLL.
InstallScript Sample
In an InstallScript custom action, you can call SprintfMsiLog to write a string to the MSI log file. For example, the following InstallScript code prototypes and defines an InstallScript custom action called LoggingTestInstallScript.

#include "ifx.h"
// standard custom action prototype
export prototype LoggingTestInstallScript(HWND);
// custom action definition
function LoggingTestInstallScript(hInstall)
begin
     SprintfMsiLog("Calling LoggingTestInstallScript...");
     // return success to MSI
     return ERROR_SUCCESS;
end;
In order to be called, the custom action must be scheduled in the sequences. For this example, open the Custom Actions view and create an immediate-mode InstallScript custom action called callLoggingTest that calls the LoggingTestInstallScript function, and schedule it to run after LaunchConditions.

Click here for the full article from InstallShield which details on writing to MSI Log file from VBScript as well as DLL Custom Actions.

No comments:

Post a Comment