How to send email msg if a windows service stops?
How to send email msg if a windows service stops?
July 19th, 2011 1:44pm

Skoppula, I am infering you are talking about if a system service stops you want an email notification. There are a couple routes you can take on this. 1. You can write your own applet 2. You can use some of the great MS products like SCCOM or MOM 3. There are many 3rd party applications that are in the market that can offer a whole range of system events and information to alert on. Bing! for system moniroting and alerting
Free Windows Admin Tool Kit Click here and download it now
July 19th, 2011 1:52pm

Hi Jason, thanks for repley. Any idea..about batch files/VBscripts for this.
July 19th, 2011 2:03pm

To further elaborate Jason's recommendations... For a stand-alone system, the easiest method is to have the system "run a program" when the service fails. You can set that configuration in the "Recovery" tab when accessing the properties of the service. The program you will run will be most likely a vbscript. This vbscript will send out the message. YOu'll notice that in the recovery tab, when you select the action from the drop down of "first failure", other options are presented so you can "pipe" in information to your vbscript about the service. So, you can have one script used for more than one service by sending the script information about the service that failed. For a scenario where you want to monitor services for many systems, the MS product that does this is Operations Manager (MOM/SCOM). Product used to be called MOM, Microsoft OPerations Manager, but is now referred to SCOM, Systems Center Operations Manager. More info on SCOM: http://www.microsoft.com/systemcenter/en/us/operations-manager.aspx. Visit anITKB.com, an IT Knowledge Base. Follow me on Facebook.
Free Windows Admin Tool Kit Click here and download it now
July 19th, 2011 2:03pm

Hi JM, Thanks alot for repley.. Could you pl provide me VBscript for the same if you have..thank in advance. I need it for single machine and couple of services.
July 19th, 2011 2:11pm

I have a sample one that you can use and modify to your needs. Its a stand-alone script so it will need an adjustment to accept parameters if you want to reuse it for different services. Send an Email Message Using VBScript http://www.anitkb.com/2010/03/send-email-message-using-vbscript.html I also have an example on how to pass parameters to a vbscript. How to Pass Parameters to VBScript http://www.anitkb.com/2010/10/how-to-pass-parameters-to-vbscript.html Hope that helps... Visit anITKB.com, an IT Knowledge Base. Follow me on Facebook.
Free Windows Admin Tool Kit Click here and download it now
July 19th, 2011 2:24pm

In windows 2008, you can generate an email alert based on an event log or ID. Review the following blog: http://portal.sivarajan.com/2010/04/generate-email-alert-to-event-attach.html Santhosh Sivarajan | MCTS, MCSE (W2K3/W2K/NT4), MCSA (W2K3/W2K/MSG), CCNA, Network+ Houston, TX Blogs - http://blogs.sivarajan.com/ Articles - http://www.sivarajan.com/publications.html Twitter: @santhosh_sivara - http://twitter.com/santhosh_sivara This posting is provided AS IS with no warranties,and confers no rights.
July 19th, 2011 2:26pm

As an example, here is a Powershell script that checks that the BITS service is running. It does this every 60 seconds, and if it is not running, sends an email to the administrator: while ((Get-Service "BITS").status -eq "Running") {Start-Sleep -Seconds 60} Send-MailMessage -From bits@ps.local -To admin@ps.local -Body "Bits Stopped" -SmtpServer server1 Alternatively, you can put a .cmd file in your Recovery Tab of the service, as noted by JM, and use the following command: Powershell Send-MailMessage ..... If you found this post helpful, please give it a "Helpful" vote. If it answered your question, remember to mark it as an "Answer".
Free Windows Admin Tool Kit Click here and download it now
July 19th, 2011 3:18pm

Nicely done with powershell Bigteddy... Visit anITKB.com, an IT Knowledge Base. Follow me on Facebook.
July 19th, 2011 3:43pm

Very cool I never knew this. Thanks for this post. I will definitely use this feature.Dave - http://www.dms-itconsulting.com
Free Windows Admin Tool Kit Click here and download it now
July 19th, 2011 9:56pm

Thanks, JM, it is rather cute, isn't it. I LOVE Powershell!If you found this post helpful, please give it a "Helpful" vote. If it answered your question, remember to mark it as an "Answer".
July 20th, 2011 12:31pm

As an example, here is a Powershell script that checks that the BITS service is running. It does this every 60 seconds, and if it is not running, sends an email to the administrator: while ((Get-Service "BITS").status -eq "Running") {Start-Sleep -Seconds 60} Send-MailMessage -From bits@ps.local -To admin@ps.local -Body "Bits Stopped" -SmtpServer server1 Alternatively, you can put a .cmd file in your Recovery Tab of the service, as noted by JM, and use the following command: Powershell Send-MailMessage ..... If you found this post helpful, please give it a "Helpful" vote. If it answered your question, remember to mark it as an "Answer". Bigteddy, can you advise on how to make this run say, forever? I ran it in Powershell Console, but after it sends the email one time, I'm back at a command prompt.TravisJ
Free Windows Admin Tool Kit Click here and download it now
March 30th, 2012 1:30pm

Hello Travis and others, Thanks for your simple & easy script. As I understand through testing it, the script runs in a powershell window, until it finds the service is stopped. Then it sends an email and quits. What I would like to do, is the following: - start the script in the background (i.e. 'silent') when the server starts; - run the script without logging on; - keep the script running, even when it found that the service wasn't running (so the script shouldn't quit after sending the alert). As an alternative, it would be OK to, if the script somehow restarted after restarting the service. Would anybody know a way to get this to work? Kind regards, Marco Visser
May 23rd, 2012 10:33am

Hello Travis and others, Thanks for your simple & easy script. As I understand through testing it, the script runs in a powershell window, until it finds the service is stopped. Then it sends an email and quits. What I would like to do, is the following: - start the script in the background (i.e. 'silent') when the server starts; - run the script without logging on; - keep the script running, even when it found that the service wasn't running (so the script shouldn't quit after sending the alert). As an alternative, it would be OK to, if the script somehow restarted after restarting the service. Would anybody know a way to get this to work? Kind regards, Marco Visser Must be a way to loop this. I am curious as well.
Free Windows Admin Tool Kit Click here and download it now
May 24th, 2012 11:26am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics