This website uses cookies. By clicking Accept, you consent to the use of cookies. Click Here to learn more about how we use cookies.
Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
- Revenera Community
- :
- InstallShield
- :
- InstallShield Forum
- :
- MsiLogFileLocation-How to copy the log file to target folder?
Subscribe
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Subscribe
- Mute
- Printer Friendly Page
Jan 11, 2012
05:06 AM
MsiLogFileLocation-How to copy the log file to target folder?
Hן All.
As I understand, I can't control the MsiLogFileLocation Property and decide under what folder to create the log file – it'll created under %TEMP%\MSI…..log.
I want that after the installation the log file will be under folder [SETUPEXEDIR] so i wrote a function that copies the file to this folder:
I insert my function in the last phase of UI sequence and during the execution I got failed to copy error message.
I suppose that while the installation doesn't finished the log file is with read-only permissions…
How can I copy the log file (MsiLogFileLocation) to target folder as part of the installation process?
Thanks
As I understand, I can't control the MsiLogFileLocation Property and decide under what folder to create the log file – it'll created under %TEMP%\MSI…..log.
I want that after the installation the log file will be under folder [SETUPEXEDIR] so i wrote a function that copies the file to this folder:
function CopyMSILogFile2TargetDirectory(hMSI)
STRING sTempFolder, sLogPATH, sLogFileName, sourceFile, targetFile, MsiLogFileLocation;
NUMBER nvbuffer;
begin
nvbuffer = 256; MsiGetProperty(hMSI, " SETUPEXEDIR", sLogPATH, nvbuffer);
nvbuffer = 256; MsiGetProperty(hMSI, "MsiLogFileLocation", MsiLogFileLocation, nvbuffer);
sourceFile = MsiLogFileLocation;
targetFile = sLogPATH;
if (XCopyFile(sourceFile,targetFile,COMP_NORMAL) < 0) then
trace(hMSI,"-E- Failed to copy " + sourceFile + " To: " + targetFile);
else
trace(hMSI,"-I- File: " + sourceFile + " successfully copied to: " + targetFile);
endif;
end;
STRING sTempFolder, sLogPATH, sLogFileName, sourceFile, targetFile, MsiLogFileLocation;
NUMBER nvbuffer;
begin
nvbuffer = 256; MsiGetProperty(hMSI, " SETUPEXEDIR", sLogPATH, nvbuffer);
nvbuffer = 256; MsiGetProperty(hMSI, "MsiLogFileLocation", MsiLogFileLocation, nvbuffer);
sourceFile = MsiLogFileLocation;
targetFile = sLogPATH;
if (XCopyFile(sourceFile,targetFile,COMP_NORMAL) < 0) then
trace(hMSI,"-E- Failed to copy " + sourceFile + " To: " + targetFile);
else
trace(hMSI,"-I- File: " + sourceFile + " successfully copied to: " + targetFile);
endif;
end;
I insert my function in the last phase of UI sequence and during the execution I got failed to copy error message.
I suppose that while the installation doesn't finished the log file is with read-only permissions…
How can I copy the log file (MsiLogFileLocation) to target folder as part of the installation process?
Thanks
(5) Replies
Jan 11, 2012
05:43 AM
Since the log file is being written during the instalaltion I don't think you can copy it as part of your installation - at least not during the msi part. You'd have to do it afterwards. Maybe a custom action that launches an executable (and doen't wait), then the executable waits for the install to finish, then copies the log. Or a second, chained MSI for this purpose. Or a feature-dependent "pre-requisite" (which actually becomes an "after-requisite" if it's feature dependent).
The problem is access permissions: you have to do it during the elevated install phase because users don't have permissions to put a file under Program Files.
It might be better to set the desired log file location on the command line (/L parameter), however the destination folder must exist.
The problem is access permissions: you have to do it during the elevated install phase because users don't have permissions to put a file under Program Files.
It might be better to set the desired log file location on the command line (/L parameter), however the destination folder must exist.
Stefan Krueger
InstallSite.org
InstallSite.org
Jan 11, 2012
10:55 AM
Same problem but at least you control the name 🙂
BTW it might not be bad to have the log in TEMP because that's where troubleshooters will look for it.
BTW it might not be bad to have the log in TEMP because that's where troubleshooters will look for it.
Stefan Krueger
InstallSite.org
InstallSite.org
Apr 09, 2014
11:38 AM
I found a good way to do just this thing. What we do is copy the MSI log file after the user presses the Finish button at the end. It is modeled after the ShowMsiLog CA. It's an EXE Custom Action (Path Referenced in a Directory).
New Custom Action EXE type
Custom Action Name: CopyLogFile
Working Directory: SystemFolder
File Name & Command Line: xcopy.exe "[MsiLogFileLocation]" "[CommonAppDataFolder]\COMPANY_NAME\Installation Log"
Return Processing: Asynchronous (No Wait for Completion)
In-Script Execution: Immediate Execution
Execution Scheduling: Always Execute
**NOTE** Do not put it in any sequences or use conditions. This gets tied to the "Finish" Button of SetupCompleteSuccess and SetupCompeteError dialog buttons.
1) In Dialog view, expand SetupCompleteSuccess and click on "Behavior".
2) Click the Finish Pushbutton, found in the "SetupCompleteSuccess Dialog Behavior" view (we need to add our action to the list of things to do when Finish is pressed).
3) To the right, find the Finish Pushbutton Event window. Add a "DoAction" Event, Type: CopyLogFile, Condtion: 1 (now, when the button is pressed, the setup finishes and this file copies to your custom location
In your case you would do the following in CopyLogFile:
xcopy.exe "[MsiLogFileLocation]" "[INSTALLDIR]"
And, this is SO COOL. You can just get rid of renaming your log file. Let the system auto name it for you so you will get a new log file each time (each one can be analysed individually, GREAT FOR SUPPORT PURPOSES, which is why I save em to a custom location. A customer can just email me all the MSI*.log files and I have a history every time the installer was run, what it was doing, etc...)
EDIT:
So, this approach works great with a GUI. I am currently trying to find a way to do this when Silent Install mode is run.
Does anyone have any answer for that? Thanks SO MUCH in advance.
New Custom Action EXE type
Custom Action Name: CopyLogFile
Working Directory: SystemFolder
File Name & Command Line: xcopy.exe "[MsiLogFileLocation]" "[CommonAppDataFolder]\COMPANY_NAME\Installation Log"
Return Processing: Asynchronous (No Wait for Completion)
In-Script Execution: Immediate Execution
Execution Scheduling: Always Execute
**NOTE** Do not put it in any sequences or use conditions. This gets tied to the "Finish" Button of SetupCompleteSuccess and SetupCompeteError dialog buttons.
1) In Dialog view, expand SetupCompleteSuccess and click on "Behavior".
2) Click the Finish Pushbutton, found in the "SetupCompleteSuccess Dialog Behavior" view (we need to add our action to the list of things to do when Finish is pressed).
3) To the right, find the Finish Pushbutton Event window. Add a "DoAction" Event, Type: CopyLogFile, Condtion: 1 (now, when the button is pressed, the setup finishes and this file copies to your custom location
In your case you would do the following in CopyLogFile:
xcopy.exe "[MsiLogFileLocation]" "[INSTALLDIR]"
And, this is SO COOL. You can just get rid of renaming your log file. Let the system auto name it for you so you will get a new log file each time (each one can be analysed individually, GREAT FOR SUPPORT PURPOSES, which is why I save em to a custom location. A customer can just email me all the MSI*.log files and I have a history every time the installer was run, what it was doing, etc...)
EDIT:
So, this approach works great with a GUI. I am currently trying to find a way to do this when Silent Install mode is run.
Does anyone have any answer for that? Thanks SO MUCH in advance.
Apr 09, 2014
03:20 PM
I just tested this on 2008R2, Win7x86 and Win7x64 and XPSP3 and 2003SE
It works perfectly with all but XP--cuts off 20 kb of data in the log file that gets copied. Maintenance and remove events work properly though on XP
I really don't care about XP. We don't support it anymore for any of our products. End of Life means something to us.
It works perfectly with all but XP--cuts off 20 kb of data in the log file that gets copied. Maintenance and remove events work properly though on XP
I really don't care about XP. We don't support it anymore for any of our products. End of Life means something to us.