在 WIX 中强行终止 windows 服务

Kill windows service forcefully in WIX(在 WIX 中强行终止 windows 服务)
本文介绍了在 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 服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

DispatcherQueue null when trying to update Ui property in ViewModel(尝试更新ViewModel中的Ui属性时DispatcherQueue为空)
Drawing over all windows on multiple monitors(在多个监视器上绘制所有窗口)
Programmatically show the desktop(以编程方式显示桌面)
c# Generic Setlt;Tgt; implementation to access objects by type(按类型访问对象的C#泛型集实现)
InvalidOperationException When using Context Injection in ASP.Net Core(在ASP.NET核心中使用上下文注入时发生InvalidOperationException)
LINQ many-to-many relationship, how to write a correct WHERE clause?(LINQ多对多关系,如何写一个正确的WHERE子句?)