Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Service Stop Notice

Status
Not open for further replies.

robros

Programmer
May 22, 2001
241
US
Hello Everyone
I would to have the following.
When a service stops can I have windows send an message out via email?

any help on this would be great.

Thanks


Your Al Meyers Kid..You Look Pretty Stupid To me.
 
If the service fails you can set it up to run a file in the service's properties.
 
Adding to what vbrocks says you could use something like the following:

Create a batch file that runs a vbscript to send a message via CDO

Here's a sample batch file snippet

@echo off
cscript.exe c:\mail.vbs

Here's a sample script to send the message via CDO

Set objMessage = CreateObject("CDO.Message")
Set objMessage = CreateObject("CDO.Message")
objMessage.Subject = "Service Alert"
objMessage.Sender = "sender@YourDomain.com"
objMessage.To = "recipient@YourDomain.com"
objMessage.TextBody = "NOTICE: The xyz service has stopped responding..."
objMessage.Send
 
FYI - You probably don't even need the batch file just set the service to run cscript.exe with c:\mail.vbs as the argument.
 
Thanks


Your Al Meyers Kid..You Look Pretty Stupid To me.
 
robros,

Did it work for you? Worked for me from home and on an XP machine at work but not from a win2K Adv server machine at work. Didn't have time to troubleshoot it today, though.
 
Your machine at work will probably have some trouble with it because you are not specifying the SMTP server info. This is the script I use for the same purpose. You will need to edit the script with your info for your SMTP server, domain name and the email address you want the message sent to. All of these settigns are up near the top of the script.

'==========================================================================
'
' 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 = "myhouse.com"
' Set the SMTP server IP
oMyIP = "68.6.19.4"
' 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 = " _
cdoSendUsingPort = 2, _
cdoSMTPServer = "
'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



I hope you find this post helpful. Please let me know if it was.

Regards,

Mark
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top