0

I'm trying to access services on a remote computer (a virtual machine in my case). To do this I'm using

ServiceController[] services = ServiceController.GetServices("COMPUTERNAME");

I'm getting an error message saying "Cannot open Service Control Manager. The operation might require other privileges". However, the same error message displays when I change the computer name to a gibberish string which refers to no remote machine. I therefore don't know whether the problem is with permissions for accessing services or is something else entirely.

I've tried using impersonate but I'm getting the same sort of problem where it says it might need permissions though it gives exactly the same error message when you put gibberish for the computer name.

So I guess my question is along the lines of: Is this the right approach for accessing services on a remote machine? How do I determine using C# whether it's actually recognizing the remote computer referred to in the code?

Ghasem
  • 14,455
  • 21
  • 138
  • 171
JamToast
  • 59
  • 7
  • In Visual Studio, right click the project and select Add->Service Reference.... See if you can access the services using that dialog. – Steve Wellens Jan 02 '16 at 01:09
  • No, that doesn't even work for services on the same computer even though I can access them fine from the service controller. – JamToast Jan 02 '16 at 02:00
  • Are these computers that are on a domain? Would it require the FQDN? – Tim Jan 02 '16 at 02:59

0 Answers0