title: Querying if a Windows Service is disabled (without using the Registry)?
body: <p>Is there a .NET (C#) method or API call that I can use to query if a Windows Service is disabled? The relevant MSDN article <a href="http://support.microsoft.com/kb/103000" rel="nofollow noreferrer">is here</a>.</p>
  
  <p>I want to avoid querying the registry directly. Below is some of the code that I am using right now (and it works). However I am looking for something more elegant and less invasive.</p>
  
  <pre><code>const String basepathStr = @"System\CurrentControlSet\services\";
  String subKeyStr = basepathStr + servicenameStr;
  
  using (RegistryKey key = Registry.LocalMachine.OpenSubKey(subKeyStr))
  {
      return (int) key.GetValue("Start");
  }
  </code></pre>
  
  <p>I did find a <a href="https://stackoverflow.com/questions/1939611/get-the-disabled-status-of-a-windows-service">simliar question</a> but I was hoping for a better answer since the answers are presumably outdated (3 years have passed).</p>