Windows 服务并将其设置为禁用
有没有办法让应用程序收到特定服务被设置为禁用的通知? 我有一个 NT 服务,我想“捕获”此事件并保留该时间以供以后使用。
关于如何做到这一点有什么想法吗?
谢谢
Is there a way for an application to get notified that a specific service is set to disabled?
I have a NT service and I want to "catch" this event and keep that time for later use.
Any thoughts on how to do this?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您应该能够在 WMI 中执行一些操作来实现此目的。我认为您可以订阅您感兴趣的
Win32_Service
特定实例的__InstanceModificationEvent
通知。另一方面,如果有人要停止并禁用服务,他们只会停止并禁用监视它的进程。所以无论如何你都赢不了。
为什么不保护服务 ACL,以便只有管理员才能停止和禁用它?事实上,无论如何,这都是默认设置。如果用户拥有管理员权限,那么您就已经失败了。
You ought to be able to do something in WMI to do with that. I think that you can subscribe to the
__InstanceModificationEvent
notification for the particular instance ofWin32_Service
that you're interested in.On the other hand, if someone's going to stop and disable the service, they'll just stop and disable the process monitoring it. So you're not going to win, anyway.
Why don't you just secure the service ACL so that only Administrators can stop and disable it? This is, in fact, the default anyway. And if the user's got admin privileges, you've already lost.
我的客户端应用程序的其他部分将轮询并调用 RegNotifyChangeKeyValue 以查看该服务是否被禁用,我会记下它......
other parts of my client app will poll and call RegNotifyChangeKeyValue to see if the service is disabled, it is I will make note of it...