我们有一个通过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?
'""[#"[INSTALLFOLDER]\Lifen.exe"]"" "--new-version"'
'""[#"[INSTALLFOLDER]\Lifen.exe"]"" "--new-version"'
有没有人有想法?
提前致谢
<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位可执行文件,请改用WixQuietExec64
自定义操作和WixQuietExec64CmdLine
属性。