![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | restart service and email I need a script that I can call from the service recovery options. I need it to start the crashed service. Get the relevant event from the system event list. Send an email with the event in the body. Does anyone have something like this? |
My System Specs![]() |
| | #2 (permalink) |
| | Re: restart service and email On Apr 24, 5:07*pm, sjkraal <sjkr...@xxxxxx> wrote: Quote: > I need a script that I can call from the service recovery options. > I need it to start the crashed service. > Get the relevant event from the system event list. > Send an email with the event in the body. > > Does anyone have something like this? # COMMENT: Check if Process is running. If not start it and send an # # ============================================================================================== if (!(gps myproc -ea 0)) { $MyProcCMD = "c:\program file\my program\myproc.exe /switces" #<-- cmd to start proc $wmi = ([wmiclass]"win32_process").Create($MyProcCMD) if ($wmi.returnvalue -eq 0) { $smtp = new-object system.net.mail.smtpClient ("smtp.domain.com") $mail = new-object System.Net.Mail.MailMessage $mail.from = "f...@xxxxxx" $mail.to.add("t...@xxxxxx") $mail.subject = "MyProc was in Stopped state. Successfully restarted." $mail.body = "bla-bla-bla" $mail.IsBodyHtml = $true $smtp.send($mail) } |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Services Problem. Have Stopped a service..now can't restart it. Help Plz! | General Discussion | |||
| Controlling service restart timeout with WMI | VB Script | |||
| vista - keep needing to restart dns service | Vista networking & sharing | |||
| Email causing restart | Vista mail | |||
| How do I restart the service of Windows Security Center? | Vista security | |||