我们有一个通过 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
bat 脚本:
@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 —新版本
我尝试了多种写法:
'[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?
'"""[#"[INSTALLFOLDER]\Lifen.exe"]""“--新版本”'
'"""[#"[INSTALLFOLDER]\Lifen.exe"]""“--新版本”'
有人有想法吗?
提前致谢
最佳答案
基本语法
<Property Id="WixQuietExecCmdLine" Value='"[INSTALLFOLDER]Lifen.exe" --new-version'/>
- 您始终需要引用路径,因为它们可能包含空格。
- 您文件夹属性后不需要反斜杠,例如
[INSTALLFOLDER]
,因为 MSI 运行时确保所有安装文件夹属性的值都以反斜杠结尾。 参数也一样,如果有空格需要加引号。如果你有一个常量参数,比如
--new-version
在您确定没有空格的地方,您不需要引用。对于包含属性引用的参数,始终引用更安全。例如:<Property Id="WixQuietExecCmdLine" Value='"[INSTALLFOLDER]Lifen.exe" "--new-version=[NEWVERSION]"'/>
如果您有疑问,请查看详细日志,看看WixQuietExecCmdLine
的实际值是否正确。是你所期望的。通过调用 msiexec -l*v logfile.txt <OtherParameters>
激活详细日志记录.
64 位可执行文件
要运行 64 位可执行文件,请使用 WixQuietExec64
自定义操作和 WixQuietExec64CmdLine
属性(property)代替。
关于wix - 将命令行参数传递给 WiX 自定义操作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54891721/