Windows 服务中的 ServiceController

发布于 2024-09-08 23:31:16 字数 194 浏览 0 评论 0原文

我正在尝试使用 ServiceController.GetServices() 方法来获取所有服务的列表。在控制台应用程序中,它工作正常,但如果我在 Windows 服务中调用此方法,我会得到一个空列表。这似乎是一个身份验证问题,但我使用了所有帐户选项(本地系统、本地服务、网络服务、用户[这是本地管理员]),没有运气。

有什么建议吗?

谢谢

I'm trying to use ServiceController.GetServices() method to get the list of all the services. In a console application, it works OK, but I get an empty list if I call this method in a windows service. That seems an authentication issue, but I used all the account options ( Local System, Local Service, Network Service, User[which is a local admin] ), no luck.

Is there any suggestion?

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

水染的天色ゝ 2024-09-15 23:31:17

同意,这一定是用户帐户权限问题。枚举需要通过调用本机 OpenSCManager() API 函数来开始。这是一个非常特权的功能,SDK 文档指出需要管理员访问权限。您必须配置该服务并为其提供管理员登录名。听起来你已经尝试过这个了。稍微担心一下 UAC,然后在 serverfault.com 上询问更多有关它的问题,该网站被认为是安全专家的所在地。

Agreed, this has to be a user account privilege issue. Enumeration needs to get started by calling the native OpenSCManager() API function. This is a very privileged function, the SDK docs note that administrator access is required. You would have to configure the service and give it an admin login. Sounds like you already tried this. Worry about UAC a bit, then ask more questions about it at serverfault.com, presumed home of the security experts.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文