title: Querying a Windows Service status in C# on a Web Application
body: <p>We are using the ServiceController object to query if our Service is running or not. Our web application that is performing the query is using Impersonation for security/login.</p>
  
  <pre><code>System.ServiceProcess.ServiceController sc = new System.ServiceProcess.ServiceController("myService");
  return sc.Status
  </code></pre>
  
  <p>Using an Administrator account, the query is successful. Using a limited account (non-administrator), the query is failing with a message of "Service myService was not found on computer '.'"... BUT it is only failing in Windows Server 2003 and not in Windows XP.</p>
  
  <p>I've Googled it and checked in MSDN. I didn't find anything related to the usage of ServiceController in Windows Server 2003.</p>
  
  <p>Any ideas?</p>
  
  <p>EDIT: If there is a way to query the service status without using the ServiceController that doesn't involve "security" privileges, that might work for us. We just need to get the status of the service.</p>
  
  <p>UPDATE:</p>
  
  <p>I created a simple console application that will print the status of the service. I used the "runas" command to run the application using both the Administrator and Non-Administrator account. It both worked in Windows Server 2003... Which means that this is an issue of the privilege not being properly passed to the ServiceController call in the web application? IIS security stuff perhaps?</p>
  
  <p>Thanks!</p>