title: Can't access ServiceController (InvalidOperationException) when trying to read on remote/another computer
body: <p>I have a local service running on my computer and trying to get other computers to be able to read the status of my service (whether it's running, stopped, etc.) However, I am unable to as I get an InvalidOperationException error, saying that I am unable to open Service Control Manager. Locally, I am able to, but on another remote computer I am unable to. The ServiceController (cs) object just returns an object with properties that all have the InvalidOperationException error.</p>
  
  <p>I've tried closing down all the firewalls on the other computers, tried running Visual Studio on Administrator privileges, but nothing seems to be working. I've noticed that others suggested hard coding your admin credentials and using WindowsIdentity and Impersonation but that wouldn't work for my project (as it wouldn't be a viable solution at my workplace - wouldn't make sense with the business logic as don't want to give clients any in-house credentials). </p>
  
  <p>Here's my snippet of code: </p>
  
  <pre><code>    public bool CheckServiceStatus()
      {
          try
          {
              string machineName = pubSubConfig.MachineName;
              string serviceName = pubSubConfig.ServiceName;
  
              System.ServiceProcess.ServiceController cs = new System.ServiceProcess.ServiceController(serviceName, machineName);
  
              if (cs != null &amp;&amp; cs.ServiceName == serviceName &amp;&amp; cs.Status == System.ServiceProcess.ServiceControllerStatus.Running)
              {
                  return true;
              }                
          }
          catch(Exception ex)
          {
              Trace.TraceError("Unable to check service status: /r/n {0}", ex.Message);
          }
          return false;
      }
  </code></pre>
  
  <p>The error is this:</p>
  
  <pre><code>System.InvalidOperationException: Cannot open Service Control Manager on computer '___'. 
  This operation might require other privileges. ---&gt; System.ComponentModel.Win32Exception: Access is denied
  </code></pre>
  
  <p>Does anyone know any workarounds as to how I can get other computers running my C# program to be able to read the ServiceController object? </p>
  
  <p>Thanks!</p>