在WIX中强行终止Windows服务 [英] Kill windows service forcefully in WIX

查看:62
本文介绍了在WIX中强行终止Windows服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有Windows服务,它将作为wix安装的一部分进行安装。问题在于,当前服务正在生产中,并且由于服务OnStop方法中的一些编写不佳的代码而无法停止响应。

I have windows service which will get installed as part of wix installation . Problem is that, currently service is in production and it is not responding to stop due to some poorly written code in service OnStop method .

因此,下次用户尝试安装升级版时,安装将失败,因为wix尝试停止服务时服务将永远不会停止。

So next time when the user tries to install upgraded version installation will fail because service will never stop when wix tries to stop the service .

有什么方法可以让我知道wix是否花了太多时间进行卸载,并且如果我收到该通知,可以杀死该进程?

Is there any way in which i come to know if wix is taking too much time to uninstall and i can kill the process if i get that notification ?

还有,我有什么办法可以根据产品版本取消进程?

Also, is there any way i can kill process based on product version ?

谢谢

推荐答案

我在挖矿后找到了解决方案一段时间。

I have found a solution for this after digging for sometime .

我正在创建新的C#自定义操作项目,并在InstallInitialize之前对操作进行排序。

I am creating new C# custom action project and i am sequencing my action before InstallInitialize.

在我的C#自定义操作方法中,我正在使用
FileVersionInfo.GetVersionInfo(filePath);读取现有已安装的文件版本;

In my C# custom action method, i am reading the existing installed file version by using FileVersionInfo.GetVersionInfo(filePath);

然后我正在检查想要检查的期望版本,如果条件匹配,我正在使用

Then i am checking with desired version which i want to check and if condition matches i am killing my service process using

 foreach (Process proc in Process.GetProcessesByName("ProcessName"))
 {
      proc.Kill();
      session.Log("Service Killed");
 }

为了实现此目的,必须预先安装Wix工具集v3.11.1

in order to achieve this, Wix toolset v3.11.1 has to installed beforehand

这篇关于在WIX中强行终止Windows服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆