Hello,
I'm pretty sure this is straight forward I just can't seem to get it working.
I have a service called serviceX and I want to control it from another application. The "control" is simply checking the ServiceController.Status field and calling ServiceController.Start().
The exception i get is:-
System.InvalidOperationException: Cannot open serviceX service on computer '.'. ---> System.ComponentModel.Win32Exception: Access is denied
--- End of inner exception stack trace ---
at System.ServiceProcess.ServiceController.GetServiceHandle(Int32 desiredAccess)
at System.ServiceProcess.ServiceController.Start(String[] args)
at SnippetCompiler.ServiceMonitor.StartService()
In Win32 I would specify SERVICE_QUERY_STATUS and SERVICE_START as the required access in the OpenService API call. How do I do this in managed code? I can only assume I need to use a ServiceControllerPermission object but I can't figure out how.
Keith.