Link to home
Start Free TrialLog in
Avatar of rm103
rm103Flag for United States of America

asked on

How can I get a script that will email someone whenever a windows service restarts?

Hello All:

I have a script that check 3 specific services and and tries to start them or leave them alone. I know need another script that will email someone when a service needs to be restarted to isolate root cause. Can someone point me to to reference to where I can view this?

Thanks!

Rm103
ASKER CERTIFIED SOLUTION
Avatar of oBdA
oBdA

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
If you just need simple VB to append to your existing script, this will do it for you- just update the email addresses and messages and the smtp server address.

Set objEmail = CreateObject("CDO.Message")
objEmail.From = "alert@domain.com"
objEmail.To = "youremail@domain.com"
objEmail.Subject = "Service is in stopped state"
objEmail.Textbody = "The x service has stopped and needs to be restarted."
objEmail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objEmail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = _
"192.168.1.1"
objEmail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objEmail.Configuration.Fields.Update
objEmail.Send

Open in new window

Avatar of rm103

ASKER

Thanks, this worked.