Kill windows service forcefully in WIX(在 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 服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在 WIX 中强行终止 windows 服务
基础教程推荐
- 如何使用 .Net 检查 Active Directory 服务器是否已启动并正在运行? 2022-01-01
- Azure Functions:CosmosDBTrigger 未在 Visual Studio 中触发 2022-01-01
- 当值可以是对象或空数组时反序列化 JSON 2022-01-01
- WPF 模态进度窗口 2022-01-01
- Moq It.Is<>不匹配 2022-01-01
- 如果有人提交恶意软件Nuget包怎么办? 2022-01-01
- C# 从 List<List<int>> 中删除重 2022-01-01
- 我应该在后面的代码中直接使用 Linq To SQL 还是使 2022-01-01
- 禁止输入少量字符,例如'<'、'&a 2022-01-01
- .NET SerialPort DataReceived 事件未触发 2022-01-01
