[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 275
  • Last Modified:

How do I make a service stopping trigger an e-mail?

I am trying to set up an auto email when a specific service stops.
0
seanweb
Asked:
seanweb
  • 5
  • 3
1 Solution
 
Elwin3Commented:
Got to the service and look at the properties. on the recovery tab on failure set to run a program. Then create a vbs script using the following code (changing the bits in bold) and then run that on failure:

Set objEmail = CreateObject("CDO.Message")

objEmail.From = "myname@myemail.co.uk"
objEmail.To = "goingto@myemail.co.uk"
objEmail.Subject = "Server down"
objEmail.Textbody = "Server1 is no longer accessible over the network."
objEmail.Configuration.Fields.Item _
    ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objEmail.Configuration.Fields.Item _
    ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = _
        "mysmtpsmarthost"
objEmail.Configuration.Fields.Item _
    ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objEmail.Configuration.Fields.Update
objEmail.Send
0
 
seanwebAuthor Commented:
That's great thanks, how can I test it though? As stopping the service manually I would guess is not picked up as a failure, right?
0
 
seanwebAuthor Commented:
Also, I assume that writing this out on notepad and saving as a .vbs file is adequate, yes?
0
When ransomware hits your clients, what do you do?

MSPs: Endpoint security isn’t enough to prevent ransomware.
As the impact and severity of crypto ransomware attacks has grown, Webroot fought back, not just by building a next-gen endpoint solution capable of preventing ransomware attacks but also by being a thought leader.

 
Elwin3Commented:
yes thats right just save as .vbs

a bit tricky to test I agree. You can obviously test the script on it's own.
0
 
seanwebAuthor Commented:
Thanks, I have tested the script and have an error on line 15, anything you can see?
0
 
Elwin3Commented:
what smartshost did you enter in the script. For example - I use a ISP called plusnet so my smarthost is relay.plus.net but rememebr this must be the smarthost of the line you are going out off.

 
0
 
seanwebAuthor Commented:
AhHa! Missed that, working perfectly now, thank you very much.
0
 
seanwebAuthor Commented:
Great script, very useful, took no time at all.
0

Featured Post

A Cyber Security RX to Protect Your Organization

Join us on December 13th for a webinar to learn how medical providers can defend against malware with a cyber security "Rx" that supports a healthy technology adoption plan for every healthcare organization.

  • 5
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now