我已经编写了一个脚本(.wsf)来在特定服务失败时触发电子邮件。对于第一次,第二次和随后的失败,我已经运行了一个程序并在该选项卡中添加了我的.wsf文件。但我没有收到电子邮件警报。我可以知道我应该怎么做才能执行该操作。采取如何在Windows服务恢复中运行Windows脚本文件
步骤:(但没有结果/不工作)
1)在运行程序选项卡,给写一个bat文件和脚本 2)的完整路径inturn调用。 wsf文件 3)在运行程序选项卡时给出管理员cmd.exe路径,并在命令行参数选项卡中给出脚本文件的路径。
注意:我已经在cmd.exe中单独执行了此操作,并且它通过发送电子邮件警报起作用。
为了使服务失败我手动停止它,重新启动它,但没有通知通知。请让我知道我应该进一步从Windows服务恢复选项卡执行脚本。我在此也添加了我的脚本。
<job>
<script language="VBScript">
Option Explicit
On Error Resume Next
Dim WshShell
set WshShell=CreateObject("WScript.Shell")
WshShell.run "cmd.exe"
WScript.Sleep 1000
WshShell.SendKeys "telnet smtp.sample.com 25"
WshShell.Sendkeys("{Enter}")
WScript.Sleep 1000
WshShell.SendKeys "EHLO sample.com"
WshShell.Sendkeys("{Enter}")
WScript.Sleep 1000
WshShell.SendKeys "MAIL FROM:[email protected]"
WshShell.SendKeys ("{Enter}")
WScript.Sleep 1000
WshShell.SendKeys "RCPT TO:[email protected]"
WshShell.SendKeys ("{Enter}")
WScript.Sleep 1000
WshShell.SendKeys "DATA"
WshShell.SendKeys ("{Enter}")
WScript.Sleep 1000
WshShell.SendKeys "Subject: Test Email"
WshShell.SendKeys ("{Enter}")
WshShell.SendKeys ("{Enter}")
WScript.Sleep 1000
WshShell.SendKeys "Body-Test Email executed by running script"
WshShell.SendKeys ("{Enter}")
WScript.Sleep 1000
WshShell.SendKeys "."
WshShell.SendKeys ("{Enter}")
WScript.Quit
</script>
</job>