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.
精彩评论