'**************************************************************** '* * '* SEND SERVICE WARNING * '* * '* This script is configued to send a warning if a service fail * '* Please remember to modify the Subject etc. to match.. * '* * '* www.kanmandet.dk * '* * '**************************************************************** '**************************************************************** '* Usage: * '* * '* Fill in the correct data under email configuration * '* then follow the guide on http://www.kanmandet.dk * '* search for "Get notified when a service fails" * '* * '**************************************************************** On Error Resume Next Set wshShell = WScript.CreateObject( "WScript.Shell" ) strComputerName = wshShell.ExpandEnvironmentStrings( "%COMPUTERNAME%" ) '**************************************************************** '* Email configuration * '**************************************************************** ' MODIFY THESE SETTINGS smtpserver = "smtp.yourdomain.com" recipient = "your-email@yourdomain.com" sender = strComputerName&"@yourdomain.com" service = "Spooler" ' Important you MUST use the REAL service name, not the displayname '**************************************************************** Set objEmail = CreateObject("CDO.Message") objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = smtpserver objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25 objEmail.Configuration.Fields.Update objEmail.From = sender objEmail.to = recipient objEmail.Subject = "ATTENTION - Service ["&service&"] failed on - "&strComputerName objEmail.send 'Start Service Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2") Set colListOfServices = objWMIService.ExecQuery ("Select * from Win32_Service Where Name ='" & Service & "'") For Each objService in colListOfServices objService.StartService() Next