cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
ThisIsEd
Level 4

Writing to the Application Log during installation

I'm working on a Basic MSI and looking for some way to write custom events to the Application log during installation. I'd like to include useful troubleshooting info by dumping some properties in the entry as well as predetermined messages.

i.e. "Invalid User/Password [USERNAME] provided"

Anyone know of any good solutions or approaches to this?
Labels (1)
0 Kudos
(10) Replies
Christoph
Level 8

What do you mean with the application log? The installer log?
0 Kudos
ThisIsEd
Level 4

"Application log" as in the one that's viewed in the Event Viewer. aka Event Logs 🙂

Basically we have an installer that we want to be able to write info there that can be pulled using WMI to see if/why the installer failed.
0 Kudos
Christoph
Level 8

Use Kernel32.OutputDebugStringW(BYVAL WSTRING) to write into the logfile.
0 Kudos
ThisIsEd
Level 4

Thanks for the suggestion Christoph, although it looks like this function is meant for writing to debug, rather than the application log. I'm looking for something that we can write to the application log.
0 Kudos
Christoph
Level 8

There seems to be an utility, present in a windows installation, that can be used to write event log entries:
http://blogs.techrepublic.com.com/datacenter/?p=243

How you do it via your 'own code', I don't know. I would think there should be a Windows API call available...?!?
0 Kudos
ThisIsEd
Level 4

Excellent! Exactly what I was looking for. Thank you

Here's a snippet of Installscript code that I'll use in a custom action that I threw together for a proof-of-concept:

function MyFunction(hMSI)   
STRING szEventCreate, szParameters;
STRING svInstallDir;
NUMBER nvBuffer;

begin
nvBuffer = 255;
MsiGetProperty(hMSI, "INSTALLDIR", svInstallDir, nvBuffer);
szParameters = " /L Application /T information /ID 33 /SO \"My Installer\" /D \"We are going to install to "+svInstallDir+"\"";
szEventCreate = WINSYSDIR^"eventcreate.exe";
LongPathToQuote(szEventCreate, TRUE);
MessageBox(szEventCreate+szParameters, INFORMATION);
LaunchApplication(szEventCreate, szParameters, "", SW_HIDE, 1000, LAAW_OPTION_HIDDEN);
end;
0 Kudos
ThisIsEd
Level 4

Got things working on WinXP and Vista, but not Windows 7. Unfortunately even trying to run eventcreate.exe from the command line gives me an access denied on a fresh install of Win7. 😞
0 Kudos
Christoph
Level 8

Are you administrator on that system => w.o.w. have you already created an admin user?
Are you launching the exe with admin rights?
0 Kudos
ThisIsEd
Level 4

I am an admin, disabling UAC allowed me to write to the application log.
0 Kudos
DebbieL
Level 17

If you run it from an elevated command prompt window, does it work?

If so, maybe you need to pass LAAW_OPTION_USE_SHELLEXECUTE. For more information, see LaunchApplication (especially the first bullet point in the Additional Information section).
0 Kudos