'==========================================================================
'
' VBScript Source File --
'
' NAME: NotifySvcFailure.vbs
'
' AUTHOR: Mark D. MacLachlan , The Spider's Parlor
' DATE : 04/15/2003
'
' COMMENT:
'
' This script can be added to a services actions to be taken on failure
'
' You must customize the entries for oDomain and oMyIP with the proper company information.
' Items to customize are on lines 28 and 30.
'=====================================
Dim oName, ODomain, oMyIP, oTo, svcName
Set svcName = WScript.Arguments
' Get the computer name
Set WshNetwork = CreateObject("WScript.Network")
oName = WshNetwork.ComputerName
' Set the company specific information
' Company Internet Domain Name
ODomain = "thespidersparlor.com"
' Set the SMTP server IP
oMyIP = "192.168.1.2"
' Where do you want the message to be delivered
oTo = "support@thespidersparlor.com"
' Set the visual basic constants as they do not exist within VBScript.
' Do not set your smtp server information here.
Const cdoSendUsingMethod = "[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/sendusing",[/URL] _
cdoSendUsingPort = 2, _
cdoSMTPServer = "[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/smtpserver"[/URL]
'Create the CDO connections.
Dim iMsg, iConf, Flds
Set iMsg = CreateObject("CDO.Message")
Set iConf = CreateObject("CDO.Configuration")
Set Flds = iConf.Fields
'SMTP server configuration.
With Flds
.Item(cdoSendUsingMethod) = cdoSendUsingPort
'Set the SMTP server address here.
.Item(cdoSMTPServer) = oMyIP
.Update
End With
'Set the message properties.
With iMsg
Set .Configuration = iConf
.To = oTo
.From = oName & "@" & oDomain
.Subject = "Service Failure"
.TextBody = "Service " & svcName & " on Server " & oName & " at company " & ODomain & " failed 2 times, the time of failure was " & now
End With
'An attachment can be included.
'iMsg.AddAttachment Attachment
'Send the message.
iMsg.Send
'MsgBox "Done"