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
- :
- Re: InstallScript Logging
Subscribe
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Apr 29, 2008
11:54 AM
InstallScript Logging
I cannot seem to find how to turn on Logging with Installscript?
I would also like to be able to write to this log file from Installscript. I have several of my own scripts and would like to add all the information taking place in them into the log file.
Any help would be appreciated.
I would also like to be able to write to this log file from Installscript. I have several of my own scripts and would like to add all the information taking place in them into the log file.
Any help would be appreciated.
(11) Replies
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Apr 29, 2008
12:41 PM
I don't think InstallScript has any built-in logging (to a text file, in the way MSI does) functionality. I haven't used it, but for one approach perhaps see www.installsite.org > InstallScript Samples > Misc > Log Results of Function Calls.
In any case, uninstallable system changes are written to the binary .ilg file that's created in DISK1TARGET, and you can view its contents on your development system using the log file viewer. There are also functions for writing and reading custom strings to the .ilg file.
In any case, uninstallable system changes are written to the binary .ilg file that's created in DISK1TARGET, and you can view its contents on your development system using the log file viewer. There are also functions for writing and reading custom strings to the .ilg file.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Apr 29, 2008
01:11 PM
Thank you this was very helpful.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Apr 29, 2008
01:31 PM
I too like creating log files when I do my installations. It is great way to debug the problem without having to run the installation in debug mode. Here are my routines I use.
My_log.h
My_log.rul
[CODE]#ifndef _MY_LOG_RUL_
#define _MY_LOG_RUL_
///////////////////////////////////////////////////////////////////////////////
// //
// M Y _ L O G . R U L //
// //
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// //
// //
// //
///////////////////////////////////////////////////////////////////////////////
function My_OpenLogFile(strTitle, strLogFileName)
BOOL bResult;
NUMBER nvTemp;
STRING strDateTime;
STRING strFileName;
STRING strPath;
STRING strTemp;
string szProperty[256];
begin
m_hLogFile = 0;
strFileName = strLogFileName;
if strLogFileName = "" then
strFileName = "MyInstall.log";
endif;
if GetEnvVar("TEMP", strPath) < 0 then
strPath = "C:\\";
endif;
///////////////////////////////////////////////////////////////////////////
// Make sure that the directory exists //
///////////////////////////////////////////////////////////////////////////
if (ExistsDir(strPath) != EXISTS) then
if strPath != "C:\\" then
strPath = "C:\\";
else
return FALSE;
endif;
endif;
///////////////////////////////////////////////////////////////////////////
// Open The UpgradeList.txt File //
///////////////////////////////////////////////////////////////////////////
bResult = TRUE;
OpenFileMode(FILE_MODE_APPEND);
if CreateFile(m_hLogFile, strPath, strFileName) = 0 then
GetSystemInfo (DATE, nvTemp, strDateTime);
GetSystemInfo (TIME, nvTemp, strTemp);
strDateTime = strDateTime +" "+ strTemp;
if strTitle = "" then
//nvTemp = SizeOf(szProperty);
//MsiGetProperty(ISMSI_HANDLE, "Title", szProperty, nvTemp);
//strTitle = szProperty;
endif;
My_AddToLog("///////////////////////////////////////////////////////////////////////////////");
My_AddToLog("// "+ strTitle +": "+strDateTime);
My_AddToLog("///////////////////////////////////////////////////////////////////////////////");
else
bResult = FALSE;
endif;
return bResult;
end;
///////////////////////////////////////////////////////////////////////////////
// //
// //
// //
///////////////////////////////////////////////////////////////////////////////
function My_AddToLog(strValue)
begin
if m_hLogFile != 0 then
WriteLine(m_hLogFile, strValue);
endif;
end;
///////////////////////////////////////////////////////////////////////////////
// //
// //
// //
///////////////////////////////////////////////////////////////////////////////
function My_CloseLogFile()
NUMBER nvTemp;
STRING strDateTime;
STRING strTemp;
begin
///////////////////////////////////////////////////////////////////
// Close The UpgradeList.txt File //
///////////////////////////////////////////////////////////////////
GetSystemInfo(DATE, nvTemp, strDateTime);
GetSystemInfo(TIME, nvTemp, strTemp );
strDateTime = strDateTime +" "+ strTemp;
My_AddToLog("");
My_AddToLog("///////////////////////////////////////////////////////////////////////////////");
My_AddToLog("// Close Log File... "+strDateTime);
My_AddToLog("///////////////////////////////////////////////////////////////////////////////");
if (CloseFile(m_hLogFile) < 0) then
return FALSE;
else
m_hLogFile = 0;
endif;
end;
///////////////////////////////////////////////////////////////////////////////
// //
// T H E E N D ? //
// //
///////////////////////////////////////////////////////////////////////////////
#endif
[/CODE]
How to use
Explanation:
There are three functions to be concerned about.
My_OpenLogFile
My_AddToLog
My_CloseLogFile
My_OpenLogFile --
When the log file is created, it will be placed in the Temp directory of the user who is installing it. For example, "C:\Documents and Settings\UserName\Local Settings\Temp". It gets this information by grabing the "TEMP" envrioment variable. If the call failes, the location of the log file is hard coded to be, "C:\".
My_AddToLog --
Adds a single string to the end of the log file.
My_CloseLogFile --
Close the log file.
I hope this works for you...
My_log.h
///////////////////////////////////////////////////////////////////////////////
// //
// I n s t a l l S h i e l d . h D e c l a r a t i o n s //
// //
///////////////////////////////////////////////////////////////////////////////
#ifndef _MY_LOG_H_
#define _MY_LOG_H_
///////////////////////////////////////////////////////////////////////////////
// N C L L o g F u n c t i o n s //
///////////////////////////////////////////////////////////////////////////////
prototype My_OpenLogFile(BYVAL STRING, BYVAL STRING);
external prototype My_AddToLog(BYVAL STRING);
prototype My_CloseLogFile();
///////////////////////////////////////////////////////////////////////////////
//
///////////////////////////////////////////////////////////////////////////////
NUMBER m_hLogFile;
///////////////////////////////////////////////////////////////////////////////
// //
// E n d o f . h F i l e //
// //
///////////////////////////////////////////////////////////////////////////////
#endif
My_log.rul
[CODE]#ifndef _MY_LOG_RUL_
#define _MY_LOG_RUL_
///////////////////////////////////////////////////////////////////////////////
// //
// M Y _ L O G . R U L //
// //
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// //
// //
// //
///////////////////////////////////////////////////////////////////////////////
function My_OpenLogFile(strTitle, strLogFileName)
BOOL bResult;
NUMBER nvTemp;
STRING strDateTime;
STRING strFileName;
STRING strPath;
STRING strTemp;
string szProperty[256];
begin
m_hLogFile = 0;
strFileName = strLogFileName;
if strLogFileName = "" then
strFileName = "MyInstall.log";
endif;
if GetEnvVar("TEMP", strPath) < 0 then
strPath = "C:\\";
endif;
///////////////////////////////////////////////////////////////////////////
// Make sure that the directory exists //
///////////////////////////////////////////////////////////////////////////
if (ExistsDir(strPath) != EXISTS) then
if strPath != "C:\\" then
strPath = "C:\\";
else
return FALSE;
endif;
endif;
///////////////////////////////////////////////////////////////////////////
// Open The UpgradeList.txt File //
///////////////////////////////////////////////////////////////////////////
bResult = TRUE;
OpenFileMode(FILE_MODE_APPEND);
if CreateFile(m_hLogFile, strPath, strFileName) = 0 then
GetSystemInfo (DATE, nvTemp, strDateTime);
GetSystemInfo (TIME, nvTemp, strTemp);
strDateTime = strDateTime +" "+ strTemp;
if strTitle = "" then
//nvTemp = SizeOf(szProperty);
//MsiGetProperty(ISMSI_HANDLE, "Title", szProperty, nvTemp);
//strTitle = szProperty;
endif;
My_AddToLog("///////////////////////////////////////////////////////////////////////////////");
My_AddToLog("// "+ strTitle +": "+strDateTime);
My_AddToLog("///////////////////////////////////////////////////////////////////////////////");
else
bResult = FALSE;
endif;
return bResult;
end;
///////////////////////////////////////////////////////////////////////////////
// //
// //
// //
///////////////////////////////////////////////////////////////////////////////
function My_AddToLog(strValue)
begin
if m_hLogFile != 0 then
WriteLine(m_hLogFile, strValue);
endif;
end;
///////////////////////////////////////////////////////////////////////////////
// //
// //
// //
///////////////////////////////////////////////////////////////////////////////
function My_CloseLogFile()
NUMBER nvTemp;
STRING strDateTime;
STRING strTemp;
begin
///////////////////////////////////////////////////////////////////
// Close The UpgradeList.txt File //
///////////////////////////////////////////////////////////////////
GetSystemInfo(DATE, nvTemp, strDateTime);
GetSystemInfo(TIME, nvTemp, strTemp );
strDateTime = strDateTime +" "+ strTemp;
My_AddToLog("");
My_AddToLog("///////////////////////////////////////////////////////////////////////////////");
My_AddToLog("// Close Log File... "+strDateTime);
My_AddToLog("///////////////////////////////////////////////////////////////////////////////");
if (CloseFile(m_hLogFile) < 0) then
return FALSE;
else
m_hLogFile = 0;
endif;
end;
///////////////////////////////////////////////////////////////////////////////
// //
// T H E E N D ? //
// //
///////////////////////////////////////////////////////////////////////////////
#endif
[/CODE]
How to use
#include "ifx.h"
#include "My_Log.h"
function OnBegin()
begin
My_OpenLogFile("My Product Name", "LogFile_Name.log");
My_AddToLog("This is a log file test...");
end;
function OnEnd()
begin
My_CloseLogFile();
end;
#include "My_Log.rul"
Explanation:
There are three functions to be concerned about.
My_OpenLogFile
My_AddToLog
My_CloseLogFile
My_OpenLogFile --
When the log file is created, it will be placed in the Temp directory of the user who is installing it. For example, "C:\Documents and Settings\UserName\Local Settings\Temp". It gets this information by grabing the "TEMP" envrioment variable. If the call failes, the location of the log file is hard coded to be, "C:\".
My_AddToLog --
Adds a single string to the end of the log file.
My_CloseLogFile --
Close the log file.
I hope this works for you...
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Apr 29, 2008
02:00 PM
Yes, this will, it is very clean and similar to what I was doing with vbscripts logging extra work taking place in my MSI projects. This is the first time using an Installscript project and is new and differant, but i like the control I have better. Thank you for the code! 🙂
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Apr 29, 2008
04:28 PM
You are welcome...
Just to let you know, this code has worked for me since Install Shield 6. So it is backward compatible and seems to be able to be used in the current versions of Install Shield.
Just to let you know, this code has worked for me since Install Shield 6. So it is backward compatible and seems to be able to be used in the current versions of Install Shield.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Apr 29, 2008
04:52 PM
Thank you for your help.
I am going over the code to see about adding in an Error Log ability so one can write all data to a main log file and also only write errors to an error log that can be presented at the end.
I am going over the code to see about adding in an Error Log ability so one can write all data to a main log file and also only write errors to an error log that can be presented at the end.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎May 27, 2008
04:00 PM
Looking for a way to log if files are not copied over during the install process. I have dlls that seem to not always get updated depending on if IIS is stopped or not. Is there a way to see if it was copied successfully or if it fails to be copied to the .
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎May 27, 2008
04:13 PM
There are various transfer events you could override in your script to determine if a file is being installed, such as OnInstallingFile and OnInstalledFile. The OnFileLocked, OnFileReadOnly, and OnFileError events provide some additional detail that could help determine if there was some issue encountered while installing a file.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎May 27, 2008
05:07 PM
I was using these 2 events (OnInstallingFile and OnInstalledFile) but it slowed down my installation bad when logging everything so I was looking to just log errors. So I think I will try the addtional events you mentioned. Thank you for the information, this will help a great deal.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎May 28, 2008
12:12 PM
Ok, I guess I need help on where everything is called, I was trying to use featureevents like MyFeature1_Installing(), MyFeature1_Installed(), MyFeature2_Installing() and MyFeature2_Installed().
I wrote to the logs in each one something like this.
except it seems to write all of these out before it even starts to copy the files for MyFeature1. How or where should I do things since these functions seem to be called prior to the actual feature being installed.
I wrote to the logs in each one something like this.
function MyFeature1_Installing()
begin
writeToLog("Preparing MyFeature1 for Installation");
end;
function MyFeature1_Installed()
begin
writeToLog("MyFeature1 Installation completed");
My_PerformTasks1();
end;
function MyFeature2_Installing()
begin
writeToLog("Preparing MyFeature2 for Installation");
end;
function MyFeature2_Installed()
begin
writeToLog("MyFeature2 Installation completed");
My_PerformSomeTasks2()
end;
except it seems to write all of these out before it even starts to copy the files for MyFeature1. How or where should I do things since these functions seem to be called prior to the actual feature being installed.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎May 30, 2008
02:29 PM
I got this fixed it is working correctly now, I somehow got the components moved into the second feature instead of the first. So the way I have it is correct.
![](/skins/images/8C9D13A71C7F7695F3262372C0172D68/responsive_peak/images/icon_anonymous_message.png)