

| Start Automatic Services That Have Stopped |
|
|
|
|
I hate it when I reboot a server or when we had a wind storm the other day it kept knocking out power and out UPS kept wanting to shut down the server gracefully.
-----Copy everything below this line----- 'This script will check a server and make sure all Automatic services are Started
strComputer = "." i = 0 intLongSleep = 600000 intShortSleep = 60000
WScript.Sleep intLongSleep
Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set colRunningServices = objWMIService.ExecQuery("Select * from Win32_Service")
For Each objService in colRunningServices 'WScript.Echo objService.Name & VbTab & objService.StartMode & objService.Started If objService.StartMode = "Auto" Then 'WScript.Echo "Found Mode" Redim Preserve arrStartMode(i) arrStartMode(i) = objService.Name i = i + 1
Start = LBound(arrStartMode) sEnd = UBound(arrStartMode) 'WScript.Echo objService.Name & VbTab & objService.StartMode & " " & objService.Started StartSVC() Else End If Next
Function StartSVC() If objService.Started = False Then 'WScript.Echo objService.Name & VbTab & objService.StartMode & " " & objService.Started objService.StartService() WScript.Sleep intShortSleep End If End Function
-----Copy everything above this line-----
This information is provided "AS IS" with no warranties expressed or implied. Advertisements
|










