1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
| Function StrInArr(strIn, arrIn)
Dim strTmp, boolOut
boolOut = False
For Each strTmp In arrIn
If StrComp(strTmp, strIn, vbTextCompare) = 0 Then boolOut = True
Next
StrInArr = boolOut
End Function
Dim arrServices
strComputer = "."
arrServices = Array("SSIE", "wscsvc", "Dhcp", "Dnscache", "netman", "AudioSrv") 'Saisir ici la liste des services
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colServiceList = objWMIService.ExecQuery ("Select * from Win32_Service where StartMode = 'Disabled'") ' On sélectionne les services désactivés
For Each objService in colServiceList
If StrInArr(objservice.Name, arrServices) then ' On vérifie s'ils sont dans la liste arrServices
objservice.ChangeStartMode("Automatic") ' Si oui on les passe en démarrage automatique
if objService.state = "Stopped" Then objService.StartService() ' Et s'ils sont arrêtés, on les démarre
End if
Next |
Partager