windows-server-2003 – Windows任务调度程序电子邮件通知?
发布时间:2020-12-13 23:37:17 所属栏目:Windows 来源:网络整理
导读:我使用 Windows任务计划程序运行可执行文件,成功运行时返回0.但是,如果(1)任务无法运行,或者(2)返回代码(如果不是0),我想要一封电子邮件通知. 这是Windows Server 2003上的Windows任务计划程序可以执行的操作吗? 在我寻求根除cmd.exe [grin]的过程中,这里有
我使用
Windows任务计划程序运行可执行文件,成功运行时返回0.但是,如果(1)任务无法运行,或者(2)返回代码(如果不是0),我想要一封电子邮件通知.
这是Windows Server 2003上的Windows任务计划程序可以执行的操作吗?
在我寻求根除cmd.exe [grin]的过程中,这里有一个Powershell脚本,它也适用于你:
# attempt to run your exe. iex is an alias for the invoke-expression cmd iex c:path_to_exemyprog.exe # $? lets us know if the previous command was successful or not # $LASTEXITCODE gives us the exit code of the last Win32 exe execution if (!$? -OR $LASTEXITCODE -gt 0) { $smtpServer = "smtp.mydomain.com" $fromAddress = "sender@mydomain.com" $toAddress = "recipient@mydomain.com" $subject = "FAIL" $msgBody = "HEY,YOU GOT PROBLEMS" # This block is optional depending on your SMTP server config # You need it if your SMTP server requires authentication $senderCreds = new-object System.Net.networkCredential $senderCreds.UserName = "senderusername" $senderCreds.Password = "senderpwd" $smtpClient = new-object Net.Mail.SmtpClient($smtpServer) $smtpClient.Credentials = $senderCreds $smtpClient.Send($fromAddress,$toAddress,$subject,$msgBody) } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- 无法在Windows Server 2012中装入图像文件
- 从Windows切换到DHCP服务器的冗余linux机箱的智慧?
- iis-7 – Windows Server 2008 R2上的IIS 7.5可以处理的默认
- windows驱动程序中的预处理含义
- Windows 7触摸屏Java Swing =延迟的鼠标事件
- windows-server-2003 – 从Windows识别HP阵列逻辑驱动器
- windows – 什么可以导致DNS查找忽略主机文件条目?
- windows-server-2008-r2 – 如何使用命令行获取IIS 7.5中绑
- Windows Server 2003下配置IIS6.0+php5+MySql5+PHPMyAdmin环
- 录音 – 地铁应用中的音频捕捉
推荐文章
站长推荐
热点阅读