将命令行参数传递给WiX自定义操作

问题描述 投票:2回答:1

我们有一个通过Windows安装程序(msi)安装的桌面应用程序,我们想要添加一个自定义操作,当我们将LAUNCH_APP=1传递给cmd时重新启动.exe。

所以我有一个vbs脚本启动一个bat文件,启动安装msi(主要升级):

vbs脚本:

Set WshShell = CreateObject("WScript.Shell")
Const TemporaryFolder = 2
Dim fso: Set fso = CreateObject("Scripting.FileSystemObject")
Dim tempFolder: tempFolder = fso.GetSpecialFolder(TemporaryFolder)
WshShell.Run chr(34) & WScript.Arguments(0) & chr(34) & chr(32) & chr(34) & tempFolder & "\Lifen\update\LifenInstaller.msi" & chr(34) & chr(32) & chr(34) & WScript.Arguments(1) & chr(34), 0, True
Set WshShell = Nothing

蝙蝠脚本

@echo off 

call :start >%APPDATA%\Lifen\batMsiLog.log

:start
wmic process where "name='Lifen.exe'" delete
start /wait msiexec /i %1 /qn /norestart /log %APPDATA%\Lifen\msilog.log LAUNCH_APP=1

在我的wix安装程序(wix 3.1.0版)中有这个自定义操作:

<Property Id="WixQuietExecCmdLine" Value='"[INSTALLFOLDER]\Lifen.exe"'/>
<CustomAction Id="QtExecRestartApp" BinaryKey="WixCA" DllEntry="WixQuietExec" Execute="immediate" Return="check"/>
<InstallExecuteSequence>
  <Custom Action="QtExecRestartApp" After="InstallFinalize">LAUNCHAPP = 1</Custom>
</InstallExecuteSequence>

我不知道如何添加一个参数(如—new-version)到我的自定义操作重新启动我的exe。

最后,我想运行命令:

Lifen.exe —new-version

我尝试了各种方法来编写它:

  • '"[INSTALLFOLDER]\Lifen.exe --new-version=x.x.x"'
  • '"[INSTALLFOLDER]\Lifen.exe" "--new-version=x.x.x"'

或者在阅读此stackoverflow之后:How to add arguments to the custom action exe in Wix?

  • '"&quot;[#"[INSTALLFOLDER]\Lifen.exe"]"&quot; "--new-version"'
  • '"&quot;[#"[INSTALLFOLDER]\Lifen.exe"]"&quot; "--new-version"'

有没有人有想法?

提前致谢

wix exe command-line-arguments custom-action
1个回答
2
投票

Basic Syntax

<Property Id="WixQuietExecCmdLine" Value='"[INSTALLFOLDER]Lifen.exe" --new-version'/> 
  • 您始终需要引用路径,因为它们可能包含空格。
  • [INSTALLFOLDER]等文件夹属性之后不需要反斜杠,因为MSI运行时确保所有安装文件夹属性的值以反斜杠结尾。
  • 对于参数,如果它们可能包含空格,则需要引用。如果你有一个像--new-version这样的常量参数,你肯定知道没有空格,你就不需要引用。对于包含属性引用的参数,始终引用更安全。 E. g。: <Property Id="WixQuietExecCmdLine" Value='"[INSTALLFOLDER]Lifen.exe" "--new-version=[NEWVERSION]"'/>

如果您有疑问,请查看详细日志,看看WixQuietExecCmdLine的实际值是否符合您的预期。通过调用msiexec -l*v logfile.txt <OtherParameters>激活详细日志记录。

64-Bit Executables

要运行64位可执行文件,请改用WixQuietExec64自定义操作和WixQuietExec64CmdLine属性。

© www.soinside.com 2019 - 2024. All rights reserved.