installation - 将 msiexec 命令行参数传递给 msiexec 启动的子进程

标签 installation wix command-line-arguments

由于某种原因,我需要使用命令行提供的参数来更新配置文件,但该文件没有被更新,因此我用 c# 编写了一个小型实用程序应用程序,由 msiexec 启动。目的是获取此应用程序的命令行参数,以便它打开配置文件并在安装过程中更新它。

我的应用程序执行得很好,但是当尝试读取父进程 (msiexec) 命令行参数时,我得到类似 C:\windows\msiexec/V 的内容,而不是我在 msiexec 上指定的内容命令行(我什至没有使用 /V)

对于可能出现的问题有什么想法吗?如果您有更好的方法来处理这个问题,请提出建议。

谢谢。

更新:
抱歉造成混淆,我正在使用 WiX 安装程序,并在命令行上启动 WiX 生成的 .msi,如下所示。

C:\> msiexec /I foo.msi ARG1="v1" ARG2="v2" 

ARG1ARG2 在 Wix 安装程序脚本中定义。

我正在寻找一种通过小型应用程序访问命令行参数 ARG1="v1", ARG2="V" 的方法,该应用程序将是由 msiexec 启动(该应用程序在 Wix 安装程序脚本中指定为自定义操作)。

理想情况下,当我使用 xmlFile (也尝试过 xmlConfig)时,我的 WiX 安装程序脚本应该能够使用 v1 更新我的配置文件>,v2 但它没有发生,所以编写了一个应该能够读取 v1v2 并写入配置文件的应用程序。

使用xmlFile我收到以下错误:

ExecXmlFile: Error 0x8007006e: failed to load XML file: Error 25531. Failed to open XML file , system error: -2147024786 MSI (s) (E4!54) [18:11:36:714]: Product: -- Error 25531. Failed to open XML file , system error: -2147024786 –

没有得到任何有意义的信息。我使用 msiexec 参数 /l*v 来生成日志记录。


日志摘录:

实际上 xmlFile 应该满足我的要求,但在使用它时出现以下错误。对此的任何帮助将不胜感激。

MSI (s) (E4:00) [18:11:32:110]: Executing op: ActionStart(Name=ExecXmlFile,,) Action 18:11:32: ExecXmlFile.
MSI (s) (E4:00) [18:11:32:111]: Executing op: CustomActionSchedule(Action=ExecXmlFile,ActionType=3073,Source=BinaryData,Target=ExecXmlFile,CustomActionData=1030//cloudRecognition/connectiontype130//cloudRecognition/connectionaddress192.168.128.59;192.168.128.261030//cloudRecognition/connectionport50001;50001)
MSI (s) (E4:DC) [18:11:32:113]: Invoking remote custom action. DLL: C:\Windows\Installer\MSIA419.tmp, Entrypoint: ExecXmlFile
MSI (s) (E4:EC) [18:11:32:113]: Generating random cookie.
MSI (s) (E4:EC) [18:11:32:115]: Created Custom Action Server with PID 10104 (0x2778).
MSI (s) (E4:68) [18:11:32:402]: Running as a service.
MSI (s) (E4:68) [18:11:32:403]: Hello, I'm your 32bit Elevated custom action server.
ExecXmlFile:  Error 0x8007006e: failed to load XML file:
Error 25531. Failed to open XML file , system error: -2147024786
MSI (s) (E4!54) [18:11:36:714]: Product:  -- Error 25531. Failed to open XML file , system error: -2147024786

CustomAction ExecXmlFile 返回实际错误代码 1603(请注意,如果翻译发生在沙箱内,这可能不是 100% 准确)

最佳答案

您是否将参数作为 MSI 属性传递?如果是,那么您可以从 MSI 数据库中读取它们。检查一下:

http://www.alteridem.net/2008/05/20/read-properties-from-an-msi-file/

我猜您正在将环境特定的应用程序属性设置为配置文件?如果是这样,为什么不在配置文件中定义所有属性并使应用程序足够智能以读取正确的属性(通过检查环境)?我会那么做。

以上评论仅基于您提供的有限信息。你会有你自己的理由这样做:)

关于installation - 将 msiexec 命令行参数传递给 msiexec 启动的子进程,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13294709/

相关文章:

python - IPython %edit命令: Temporary text document it opens is read only

node.js - "npm install"nodemailer 中给定编码中的无效字符

installation - 如何安排使用MSI在下次重新启动时进行安装?

windows-7 - WiX MSI 完成后,如何以管理员身份启动应用程序?

continuous-integration - WiX 3.0 在持续集成执行时​​抛出错误 217

installation - Visual Studio 2015 社区版安装卡在 Windows 10 中

python - 安装 Pandas : UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 72: ordinal not in range(128)

bash - 如何在 bash 中获取目录列表,然后将它们展开为命令行参数?

svn - 用于迭代定义的文件名集并执行命令的 Bash 脚本

c++ - 多个 WT 应用程序可以在同一个端口上运行吗?