Hi,
I have a script that will successfully restart a single process but I need to restart 3 and strService3 is the parent so this one has to be stopped last.
Option Explicit
Dim objWMIService, objItem, objService
Dim colListOfServices, strComputer, strService1, strService2, strService3, intSleep
strComputer = "."
intSleep = 15000
WScript.Echo " Click OK, then wait " & intSleep & " milliseconds"
'On Error Resume Next
' NB strService is case sensitive.
strService1 = " 'Child1' "
strService2 = " 'Child2' "
strService3 = " 'Parent' "
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\cimv2")
Set colListOfServices = objWMIService.ExecQuery _
("Select * from Win32_Service Where Name ="_
& strService1 & " ")
For Each objService in colListOfServices
objService.StopService()
WSCript.Sleep intSleep
objService.StartService()
Next
WScript.Echo "The "& strService1 & " service has Started"
WScript.Quit
Any help is greatly appreciated!
Thanks!
I have a script that will successfully restart a single process but I need to restart 3 and strService3 is the parent so this one has to be stopped last.
Option Explicit
Dim objWMIService, objItem, objService
Dim colListOfServices, strComputer, strService1, strService2, strService3, intSleep
strComputer = "."
intSleep = 15000
WScript.Echo " Click OK, then wait " & intSleep & " milliseconds"
'On Error Resume Next
' NB strService is case sensitive.
strService1 = " 'Child1' "
strService2 = " 'Child2' "
strService3 = " 'Parent' "
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\cimv2")
Set colListOfServices = objWMIService.ExecQuery _
("Select * from Win32_Service Where Name ="_
& strService1 & " ")
For Each objService in colListOfServices
objService.StopService()
WSCript.Sleep intSleep
objService.StartService()
Next
WScript.Echo "The "& strService1 & " service has Started"
WScript.Quit
Any help is greatly appreciated!
Thanks!