Question

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

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top