Un pequeño script muy muy simple para comprobar el estado de un servicio en windows (lo comprobamos por el nombre) y reiniciarlo en el caso de que este caído.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | Option Explicit Dim objWMIService, objItem, objService, strServiceList Dim colListOfServices, strComputer, strService strComputer = "." Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" _ & strComputer & "\root\cimv2") Set colListOfServices = objWMIService.ExecQuery _ ("Select * from Win32_Service ") For Each objService in colListOfServices strServiceList = strServiceList & vbCr & _ objService.name if objService.name = "NOMBRE_SERVICIO_A_CONTROLAR" Then if objService.State = "Stopped" Then objService.StartService() End if End if Next 'objService.name 'objService.State 'objService.StartService() |
Fuentes: