如何在使用 WiX 卸载时终止进程
How to kill a process upon uninstall using WiX
我正在使用 Wix 创建 an.msi 安装文件。
当我卸载我的应用程序时,它仍然可以正常工作,我可以在任务管理器中看到它。
我已经按照 Wix 文档中的描述尝试了自定义操作的延迟执行:
https://wixtoolset.org/documentation/manual/v3/customactions/qtexec.html
但不幸的是,它不适合我。
我要执行的命令是 "taskkill /f /im myProcess.exe"
<Property Id="myProcessKill" Value="taskkill /f /im myProcess.exe"/>
<CustomAction Id="myProcessKill" BinaryKey="WixCA" DllEntry="WixQuietExec"
Execute="deferred" Return="check" Impersonate="no"/>
<InstallExecuteSequence>
<Custom Action="myProcessKill" After="InstallValidate"/>
</InstallExecuteSequence>
这使得我的msi文件在安装过程中出错。
如果我将 Return="check" 更改为 Return="ignore",msi 会完成安装,但它不会在卸载时终止我的进程。
上面的代码有什么问题?或者有没有其他方法可以在卸载时终止我的进程?
提前致谢
尝试使用带引号的 cmd.exe
并将 taskkill
传递给它,在您的情况下
<Property Id="myProcessKill" Value=""c:\windows\system32\cmd.exe" /c taskkill /f /im myProcess.exe"/>
我也不确定您的自定义操作顺序,至少您应该添加 REMOVE="ALL"
。在我们的应用程序中,我们使用 <Custom Action="CloseApplication" Before="InstallInitialize"> <![CDATA[ NOT UPGRADINGPRODUCTCODE AND REMOVE="ALL" ]]> </Custom>
也许试试:. I would try that before trying anything else to avoid dependencies to any binaries. Found this sample on github.com(未测试)。
我正在使用 Wix 创建 an.msi 安装文件。 当我卸载我的应用程序时,它仍然可以正常工作,我可以在任务管理器中看到它。
我已经按照 Wix 文档中的描述尝试了自定义操作的延迟执行: https://wixtoolset.org/documentation/manual/v3/customactions/qtexec.html 但不幸的是,它不适合我。 我要执行的命令是 "taskkill /f /im myProcess.exe"
<Property Id="myProcessKill" Value="taskkill /f /im myProcess.exe"/>
<CustomAction Id="myProcessKill" BinaryKey="WixCA" DllEntry="WixQuietExec"
Execute="deferred" Return="check" Impersonate="no"/>
<InstallExecuteSequence>
<Custom Action="myProcessKill" After="InstallValidate"/>
</InstallExecuteSequence>
这使得我的msi文件在安装过程中出错。 如果我将 Return="check" 更改为 Return="ignore",msi 会完成安装,但它不会在卸载时终止我的进程。 上面的代码有什么问题?或者有没有其他方法可以在卸载时终止我的进程? 提前致谢
尝试使用带引号的 cmd.exe
并将 taskkill
传递给它,在您的情况下
<Property Id="myProcessKill" Value=""c:\windows\system32\cmd.exe" /c taskkill /f /im myProcess.exe"/>
我也不确定您的自定义操作顺序,至少您应该添加 REMOVE="ALL"
。在我们的应用程序中,我们使用 <Custom Action="CloseApplication" Before="InstallInitialize"> <![CDATA[ NOT UPGRADINGPRODUCTCODE AND REMOVE="ALL" ]]> </Custom>
也许试试: