title: Get Windows service start type?
body: <p>In the <code>System.ServiceProcess</code> namespace, is there any kind of enumeration or other direct member to determine a Service's Start Type (Auto, Delayed Auto, On Demand, Disabled) of a <code>ServiceController</code>?</p>
  
  <p>The idea is to use an available member of that namespace (or other namespace) of the .NET framework class library to determine that thing, instead of looking into the OS registry or WMI for the service's start type, because I could do that, I'm only asking if the .NET framework exposes an easier way to determine that thing.</p>
  
  <p>Pseudo-Code written in VB.Net but I could manage a C# approach too:</p>
  
  <pre class="lang-vb prettyprint-override"><code>Public Shared Function GetStartType(ByVal svcName As String) As ServiceControllerStatus
  
      Dim svc As ServiceController = (From service As ServiceController In ServiceController.GetServices()
           Where service.ServiceName.Equals(svcName, StringComparison.OrdinalIgnoreCase)
          ).FirstOrDefault
  
      If svc Is Nothing Then
          Throw New ArgumentException("Any service found with the specified name.", "svcName")
      Else
          Using svc
              ' Note that StartTypeEnumValue does not exists.
              Return svc.StartTypeEnumValue
          End Using
      End If
  
  End Function
  </code></pre>