Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/wix/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Wix:如何强制终止进程/任务?_Wix_Wix3.5_Wix Extension - Fatal编程技术网

Wix:如何强制终止进程/任务?

Wix:如何强制终止进程/任务?,wix,wix3.5,wix-extension,Wix,Wix3.5,Wix Extension,当从用Wix创建的MSI中运行卸载时,我需要在尝试删除任何文件之前强制杀死后台运行的进程。主应用程序由一个trayicon组成,该trayicon反映bg进程监控本地windows服务的状态(在C#上制作,尽管这可能与进一步的操作无关) 我首先尝试了以下方法: <File Id='FooEXE' Name='Foo.exe' Source='..\Source\bin\Release\Foo.exe' Vital='yes' /> ... <InstallExecut

当从用Wix创建的MSI中运行卸载时,我需要在尝试删除任何文件之前强制杀死后台运行的进程。主应用程序由一个trayicon组成,该trayicon反映bg进程监控本地windows服务的状态(在C#上制作,尽管这可能与进一步的操作无关)

我首先尝试了以下方法:

<File Id='FooEXE' Name='Foo.exe' Source='..\Source\bin\Release\Foo.exe' Vital='yes' />     
...
<InstallExecuteSequence>
  <Custom Action="CloseTray" Before="InstallValidate" />
</InstallExecuteSequence>
...
<CustomAction Id="CloseTray" ExeCommand="-exit" FileKey="FooEXE" Execute="immediate" Return="asyncWait" />

...
...
确认应用程序关闭对话框后,托盘图标立即关闭,但卸载完成后,taskmgr上仍会显示Foo.Exe任务。此外,给出了以下错误消息:

这就是为什么,然后我尝试了这个:

<InstallExecuteSequence>
  <Custom Action="Foo.TaskKill" Before="InstallValidate" />
</InstallExecuteSequence>
...
<CustomAction Id="Foo.TaskKill" Impersonate="yes" Return="asyncWait" Directory="WinDir" ExeCommand="\System32\taskkill.exe /F /IM Foo.exe /T" />

...
获得相同结果后,尝试:

<Property Id="QtExecCmdLine" Value='"[WinDir]\System32\taskkill.exe" /F /IM Foo.exe'/>
...
<InstallExecuteSequence>
  <Custom Action="MyProcess.TaskKill" Before="InstallValidate" />
</InstallExecuteSequence>
...
<CustomAction Id="MyProcess.TaskKill" BinaryKey="WixCA" DllEntry="CAQuietExec" Execute="immediate" Return="ignore"/>

...
...
我从这里取的样本:

最近,当所有其他方法都失败时,我也尝试了这个方法,但没有成功:

<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">
...
<InstallExecuteSequence>
 <Custom Action="WixCloseApplications" Before="InstallValidate" />
</InstallExecuteSequence>
...
<util:CloseApplication Id="CloseFoo" CloseMessage="yes" Description="Foo is still running!" ElevatedCloseMessage="yes" RebootPrompt="yes" Target="Foo.exe" />

...
...
这一次给了我一个不同的错误:

我正在考虑建造一座雕像来纪念这个拒绝死亡的过程。。。或者认为应用程序端存在问题,我应该添加类似application.Exit()的内容;或环境。退出(0);在Program.cs中的某一行

在Wix或我的应用程序上是否还有其他方法可以尝试在卸载时成功关闭它?
谢谢

就个人而言,我认为最好的选择是内置的
CloseApplication
方法,而不是以前的选择


您因此而收到的错误(错误代码2762)是因为您试图按即时顺序安排操作,但设置了将其作为延迟操作触发的
ElevatedCloseMessage=“yes”
。要么删除此属性,要么按延迟顺序安排它。

好了,这解决了第二个问题:)谢谢!现在,我必须找出为什么这两个都没有终止任务并使其保持活动状态(我仍然在taskmgr上看到Foo.exe和第一条错误消息)。哪个用户正在运行应用程序,与您安装的应用程序相同?如果不是,则需要作为延迟操作运行,以便系统帐户终止进程。