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?