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.
When they came back up 2-3 services didn’t restart(yes auto restart was enabled). So this script will run as a scheduled task after the servers startup!
—–Copy everything below this line—–
‘This script will check a server and make sure all Automatic services are Started
On Error Resume Next
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.