jueves, 1 de agosto de 2019
servicio existe
Agregar referencia: System.ServiceProcess
Dim se As Boolean = ServiceExists("LanmanWorkstation")
Public Function ServiceExists(ByVal ServiceName As String)
Return ServiceController.GetServices.Any(Function(x) x.ServiceName.Equals(ServiceName))
End Function
Dim status As String = ServiceIsRunning("LanmanWorkstation")
Public Function ServiceIsRunning(ByVal ServiceName As String) As String
Dim sc As ServiceController = New ServiceController(ServiceName)
Select Case sc.Status
Case ServiceControllerStatus.Running ' Iniciado
Return "Running"
Case ServiceControllerStatus.Stopped ' Detenido
Return "Stopped"
Case ServiceControllerStatus.Paused ' Pausado
Return "Paused"
Case ServiceControllerStatus.StopPending ' Deteniendose
Return "Stopping"
Case ServiceControllerStatus.StartPending ' Iniciando
Return "Starting"
Case Else
Return "Status Changing" ' Desconocido
End Select
End Function
fuente
Suscribirse a:
Comentarios de la entrada (Atom)
No hay comentarios.:
Publicar un comentario