开发者

ServiceController in a Windows Service

开发者 https://www.devze.com 2023-01-06 02:34 出处:网络
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

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.开发者_StackOverflow

Is there any suggestion?

Thanks


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消