Windows Installer Deferred execution - how can we log the custom actions running in deferred mode?

╄→гoц情女王★ 提交于 2021-02-04 08:20:26

问题


In my MSI , I have added 2 custom actions to execute in deferred. I cant see these 2 custom actions in the verbose log to see whether these have executed or not. I can see for all other standard and custom actions executed in immediate mode, but not for deferred. Is this expected behavior ? Please help


回答1:


WiX & VBScript: Here are some answers showing how you can use VBScript custom actions in MSI properly - combine that with the logging approach shown below and you should find all information in your log that you write there:

  • Light-Weight Condition Testing using VBScript (WiX markup towards bottom)
  • C++ Custom Actions and Failures

UPDATE: Most likely your setup has aborted before the custom action was invoked? Or your custom action crashed and returned no error? Normally you will see entries in the log along the lines of:

"Invoking remote custom action"
"Created Custom Action Server with PID DECVAL (0xHEXVAL)."
"Hello, I'm your 32bit Impersonated custom action server."

Etc... Very cosy that last variant. "Howdy doody 32bit server".


Comprehensive Logging: Please enable verbose logging with extra debugging information and use buffer-less log writing. The latter is to avoid lost buffer when custom actions crash. The log file is written directly instead of in batches and this slows down installation dramatically. I would recommended this logging variant for your case:

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

Tip: Search for "value 3" in the log file to find errors as explained by Rob Mensching (Wix & Orca author).


MSI Logging: Some more information about msiexec.exe logging in general:

  • Enable installation logs for MSI installer without any command line arguments.
  • Stefan Kruger's installsite.org has this section on logging (very good).

WiX MSI Logging: When you use WiX's Visual Studio integration, you can create a new Custom Action project and you can use the built in logging they provide from within the custom action:

[CustomAction]
public static ActionResult CustomAction1(Session session)
{
   session.Log("Begin CustomAction1");

   return ActionResult.Success;
}

C++: The above is for a managed code C# custom action, there is a template (at least there used to be) for C++ as well. I much prefer the latter for minimal dependencies.


Custom Action Logging: Your custom action can write to the log file as follows: MSI Tip: Writing to the Log File from a Custom Action. This is done via custom action code - you might do this already?


Links:

  • Is there anyway to get msiexec to echo to stdout instead of logging to a file
  • Website is not getting created in IIS - limited edition of InstallShield
  • MSI installation log says: Note: 1: 2205 2: 3: Error
  • Website is not getting created in IIS - limited edition of InstallShield



回答2:


Github.com: Adding a new answer since the old one got messy. There is a sample project here that you can try: https://github.com/glytzhkof/all. VBScriptWriteToLog in either zip or file form (same files). This project will show a sample of how to log directly to the MSI log file from VBScript.

Snippets: Here are some extracted, key markup:

<Binary Id='CA.vbs' SourceFile='CA.vbs' />
<CustomAction Id='CA.vbs' VBScriptCall='' BinaryKey='CA.vbs' Execute='immediate' Return='ignore' />

<InstallExecuteSequence>
  <Custom Action='CA.vbs' After='InstallInitialize'>NOT Installed AND NOT REMOVE~="ALL"</Custom>
</InstallExecuteSequence>
  • Deferred / Immediate: Just change Execute='immediate' to Execute='deferred' to run deferred rather than immediate.
  • ANSI Encoding: Make sure the VBScript file is saved with ANSI text encoding.
  • Condition: That MSI condition for the custom action sequencing should make it run on fresh install and not on uninstall (or major upgrade). It is sort of a normal "relic" that I left in there.

Testing: After installation search the MSI log file for "Calling LoggingTestVBS...". If it is not there, chances are you have the wrong log file. Please see below for simplest logging command.

Express Logging: Simplest possible logging from cmd.exe.

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


来源:https://stackoverflow.com/questions/57572168/windows-installer-deferred-execution-how-can-we-log-the-custom-actions-running

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!