Function ServiceStarted(strServiceName)
Dim objWMI
On Error Resume Next
Set objWMI = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
If Err <> 0 Then
WScript.Echo "Erreur WMI. Description de l'erreur : " & Err.Description
On Error GoTo 0
ServiceStarted = False
Exit Function
End If
On Error GoTo 0
Dim colServiceList
Set colServiceList = objWMI.ExecQuery _
("Select * from Win32_Service where Name = '"& strServiceName &"'")
Dim objService
If (colServiceList.Count = 0) Then
WScript.Echo "Le service """ & strServiceName & """ est introuvable !"
ServiceStarted = False
Exit Function
Else
For Each objService in colServiceList
If objService.State = "Running" Then
WScript.Echo "Le service """ & strServiceName & """ est démarré"
ServiceStarted = True
Exit Function
Else
WScript.Echo "Le service """ & strServiceName & """ n'est pas démarré"
ServiceStarted = True
Exit Function
End If
Next
End If
End Function
ServiceStarted "Computer browser"First / Previous / Next / Last / Page 1 of 1 (1 posteets)