PDA

View Full Version : CustomAction InstallScript to Move MSI Log File?



DonAIR
09-05-2018, 11:10 AM
I am trying to move the MSI log file to our installation folder. I must be missing something simple but it just wont work for me. The following action is what I am using.


export prototype MSILogCopy(HWND);
function MSILogCopy(hMSI)

NUMBER nvSize;
STRING sMSILogNewLocation, sMSILogFile, sMSILogFileLocation;

begin
SdShowMsg("Please wait while setup copies MSI install log...", TRUE); // TURN ON INSTALL'S STATUS MESSAGE

MsiGetProperty(ISMSI_HANDLE, "MsiLogFileLocation", sMSILogFileLocation, nvSize);
MessageBox(sMSILogFileLocation,WARNING);
sMSILogNewLocation = INSTALLDIR ^ "Logs";
MessageBox(sMSILogNewLocation,WARNING);
if (XCopyFile (sMSILogFileLocation, sMSILogNewLocation, COMP_NORMAL) < 0) then
MessageBox ("XCopyFile failed", INFORMATION);
else
MessageBox ("Program files successfully copied.", INFORMATION);
endif;

SdShowMsg("", FALSE); // TURN OFF INSTALL'S STATUS MESSAGE
end;

Ultimately we are trying to grab the MSI log, copy it and rename it. I also couldn't get the RenameFile working either (as it supports renaming and moving on the fly) but figured copying it to the path is step one. The two variables about come back proper:


sMSILogFileLocation = C:\Users\xxx\AppData\Local\Temp\2\MSIxxx.LOG
sMSILogNewLocation = C:\Program Files\AIR\Logs

DonAIR
09-05-2018, 11:28 AM
when changing the code over to:


export prototype MSILogCopy(HWND);
function MSILogCopy(hMSI)

NUMBER nReturn, nvSize;
STRING sMSILogNewLocation, sMSILogFile, sMSILogFileLocation;

begin
SdShowMsg("Please wait while setup copies MSI install log...", TRUE); // TURN ON INSTALL'S STATUS MESSAGE

MsiGetProperty(ISMSI_HANDLE, "MsiLogFileLocation", sMSILogFileLocation, nvSize);
MessageBox(sMSILogFileLocation,WARNING);
sMSILogNewLocation = INSTALLDIR ^ "Logs";
MessageBox(sMSILogNewLocation,WARNING);

nReturn = XCopyFile (sMSILogFileLocation, sMSILogNewLocation, COMP_NORMAL);
if (nReturn < 0) then
MessageBox(FormatMessage(nReturn), INFORMATION);
endif;

SdShowMsg("", FALSE); // TURN OFF INSTALL'S STATUS MESSAGE
end;

I get: The system cannot find the file specified. However the file is present C:\Users\i63764\AppData\Local\Temp\2\MSI78ed6.LOG.