title: how to check service state using vbscript?
body: <p>Is there anyway to check the status of service using vbscript ? I would like to have a function for each possible service state :
  <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/ee126211%28v=vs.85%29.aspx" rel="noreferrer">LINK</a>
  Any help would be great. I did write a function for checking if service is stopped :</p>
  
  <pre><code>Public Function IsServiceStop(ByVal serviceName)
      On Error Resume Next
      Dim objServices, service
      Set oWmiService = GetObject("winmgmts:\\.\root\cimv2")
      Set objServices = oWmiService.ExecQuery("Select * from Win32_Service where Name='" &amp; serviceName &amp; "'")
      For Each service In objServices
          IsServiceStop = (service.Started = False)
          Exit Function
      Next
      IsServiceStop = True
      On Error Goto 0
  End Function
  </code></pre>