1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
|
'Fonction remontant le service et son etat
Dim objWMIService, objItem, objService
Dim colListOfServices, strComputer, intSleep
strComputer = "."
intSleep = 5000
' NB strService is case sensitive.
Set args = Wscript.Arguments
ETAT_SERVICE = args(0)
WIN_SERVICE1 = args(1)
message = "The service" & (WIN_SERVICE1) & "is in state :" & (ETAT_SERVICE)
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\cimv2")
Set colListOfServices = objWMIService.ExecQuery _
("Select * from Win32_Service Where Name ="_
& WIN_SERVICE1 & " ")
For Each objService in colListOfServices
If (ETAT_SERVICE) = "Startservice" Then
return = objService.StartService(WIN_SERVICE1)
Else If (ETAT_SERVICE) = "Stopservice" Then
return = objService.StopService(WIN_SERVICE1)
End If
End If |
Partager