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

查看:26
本文介绍了在 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天全站免登陆