验证服务是否被标记为删除 [英] Verify if a service is marked for deletion

查看:40
本文介绍了验证服务是否被标记为删除的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有时当我卸载安装程序(使用 WIX 制作)时,该服务仍标记为删除,用户必须重新启动机器才能再次安装.我如何验证该服务是否被标记为删除并告诉用户在进行其他安装之前重新启动计算机?

Sometimes when I uninstall the setup (made with WIX) the service remain marked for deletion, and the user must restart the machine to install again. How could I verify that the service is marked for deletion and tell to the user to restart the computer before making other installation?

推荐答案

一般来说,这种情况发生在某些内容仍然锁定在该服务上,阻止 Windows 删除其在注册表中的配置时.(在大多数情况下,它只是服务小程序 -- services.msc -- 在后台意外打开.)

Generally speaking, this scenario occurs when something remains latched onto that service, preventing Windows from removing its configuration in the registry. (In most cases, it's simply the Services applet -- services.msc -- left open by accident in the background.)

对于检测,我建议您阅读 CreateService 和其他服务 API.例如,如果服务被标记为删除,您将在调用 CreateService 时收到 ERROR_SERVICE_MARKED_FOR_DELETE.

For detection, I suggest you read up on CreateService and other Service API. For example, you'll receive ERROR_SERVICE_MARKED_FOR_DELETE upon calling CreateService if the service is marked for deletion.

关于您提议的重启解决方案... Windows 已经进步到几乎不需要以任何理由重启.除非您正在安装专门的内核驱动程序,否则您不需要重新启动.不要偷懒!把用户放在心上!我建议更改安装程序逻辑以检测可能存在冲突的正在运行的程序,例如服务小程序,并建议关闭.

Regarding your proposed reboot solution... Windows has advanced far enough to not require a reboot for nearly any reason. Unless you're installing specialized kernel drivers, you do not need to reboot. Don't be lazy! Keep the user in mind! I recommend altering your installer logic to detect potentially conflicting running programs, like the Services applet, and suggest closure.

这篇关于验证服务是否被标记为删除的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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