Search code examples
vb.netservicestatus

Check if SERVICE is running VBNET


I want to know if a service is running (VBNET) to return a false or true value

I found other questions with this but the codes didnt work for me..

Thanks you!


Solution

  • Use service controller class to determine whether the service is running or not.

    For Each s As ServiceController In ServiceController.GetServices()
        If s.ServiceName = "yourservicename" AndAlso s.Status = ServiceControllerStatus.Running Then
               Return True
        End If
    Next
    

    Hope this helps.