Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Enable installation logs for MSI installer without any command line arguments

How can I enable logging in my MSI project and set MsiLogFileLocation? Now I am running my setup.msi with command line arguments:

msiexec /i install.msi /l*v InstallLog.log

I want to log my work always just running setup.msi without any arguments. Are there any ways to do that?

like image 844
Mayur Avatar asked Dec 24 '22 01:12

Mayur


1 Answers

One Line Logging How-to: Install Your.msi and create a verbose log file. More below.

msiexec.exe /i C:\Path\Your.msi /L*v C:\Your.log

From the MSI SDK: "You can enable verbose logging on the user's computer by using Command Line Options, the MsiLogging property, Logging policy, MsiEnableLog, and EnableLog method".

Short Answer: So add the property MsiLogging property to your MSI's Property Table and maybe use "vp" as value (without the quotes).


Hot Debugging Tip: Search for "value 3" in the log file to find errors as explained by Rob Mensching (Wix & Orca author). MSI log files can be overwhelming otherwise. See more on log-interpretation below (yellow section).


  • Similar answer
  • On the MSI logging switches and content

Burn: WiX Burn Bundles (setup.exe launchers) have their own logging constructs (beyond the MSI-specific logging described above). In other words MSI files have their logging, and setup.exe burn launchers have theirs.

  • See this answer, and from Rob Mensching himself (WiX benevolency).
  • RECOMMENDED: https://support.firegiant.com/hc/en-us/articles/230912407

Setup.exe Extraction: Burn setup.exe bundles can also be extracted (information on extraction of MSI files and setup.exe in general) - in other words you can uncompress the setup.exe contents to an output folder. Here is an inline example (follow link for more):

dark.exe -x outputfolder setup.exe

dark.exe is a WiX binary - install WiX (WiX quick start links) first in order to extract a WiX setup.exe (as of now - might change?). More on dark.exe (section 4).


Express Logging (Verbose): Simplest possible, verbose logging from cmd.exe.

msiexec.exe /i C:\Path\Your.msi /L*v C:\Your.log

Quick Parameter Explanation:

 /i = run install sequence 
 /L*v C:\Your.log = verbose logging at specified path

Debug Logging (Verbose): Advanced, slow logging for maximum details captured.

msiexec.exe /i C:\Path\Your.msi /L*vx! C:\Your.log

Quick Parameter Explanation:

 /i = run install sequence 
 /L*vx! C:\Your.log = verbose debug logging at specified path

 The x adds extra debugging information, and the ! disables the log buffer.
 This means there is no lost log if there are any crashes.

All MSI Packages - Global Logging (policy)

Yes, you enable logging globally on the machine by setting the appropriate registry key. Each MSI launched will then cause a log file with a temporary name to be created in the TEMP folder. Sort file list by change date to get the most recent one.

Registry Key & Value: The actual registry settings:

[HKEY_LOCAL_MACHINE\Software\Policies\Microsoft\Windows\Installer]
"Logging"="voicewarmup"
"Debug"=dword:00000007

How-To: Please see this FAQ-entry from installsite.org, section "Globally for all setups on a machine": http://www.installsite.org/pages/en/msifaq/a/1022.htm for the exact procedure.

Heads-Up (technical detail): This is a very technical problem that may have a bothersome and highly unexpected pragmatic effect. A side-effect of this global logging is that any Session objects you instantiate from a script using the MSI-API will also create a log file in the TEMP folder. This can cause hundreds of log files to be created in the TEMP folder if you iterate all packages and instantiate a session object. Also in the Event Log (a big system administrator no-no!). Very specific problem, but just pointing it out. A cleanup of the temp folder and Event Log "solves" the problem - or better yet - just avoid creation Session objects. Note that your deployment tool could instantiate session objects unexpectedly. Maybe check after enabling logging so you don't get this silly problem network-wide.


Package-Specific Logging

Apart from global settings and policies, you can customize the logging per package via properties or custom actions or just specify options and logging location via the msiexec.exe command line.

Command Line: In its simplest form: msiexec.exe /i C:\Path\Your.msi /L*v C:\Your.log. Documentation for the msiexec.exe command line (look at section for switch: /L)

Properties: You can set the MsiLogging property in each package to customize logging. The MSI property MsiLogFileLocation holds the path to the log file. Use this if you want to open the log after installation.

Custom Action: You could investigate the Installer.EnableLog method of the MSI-API to customize the logging behavior for a specific MSI from a custom action. More: Windows Installer Logging.


Interpreting MSI Log Files

On the topic of interpreting log files: How to interpret an MSI Log File. And one more answer on the topic.

Direct Link: Direct PDF Link to Robert Macdonald's log guide (resurrected from Wayback).

Find Errors: And, as stated above: search for "value 3" in the log file to find errors as explained by Rob Mensching (Wix & Orca author). MSI log files can be overwhelming otherwise.

Advanced Installer: How Do I Read a Windows Installer Verbose Log File?

Logging Tool: Some information on the MSI SDK logging tool WiLogUtl.exe and how to enable debugging logging with slow, constant log writes to capture as much debugging information as possible.


Writing to Log: Writing to the MSI log file from your own custom actions is not that hard. Here is a primer on the subject from Robert Dickau: MSI Tip: Writing to the Log File from a Custom Action.

  • VBScript
  • C# / Managed code

Some Links:

  • Windows Installer Logging (lots of core information, do read)
  • Windows Installer Best Practice (verbose logging for troubleshooting)
  • MSI installation log says: Note: 1: 2205 2: 3: Error
  • In-use files not updated by MSI-installer (Visual Studio Installer project)
  • How Do I Read a Windows Installer Verbose Log File?
  • How to Reproduce MSI Install Error
  • How To Read A Windows Installer Verbose Log
  • Difference between msiexec log /lv VS /l*v
like image 133
Stein Åsmul Avatar answered May 24 '23 23:05

Stein Åsmul