Any idea about how to write a VB script to monitor the scheduled tasks and send an email notification if a scheduled task does not complete successfully. This is for Windows 2003 server.
Thanks. Wendy
Any idea about how to write a VB script to monitor the scheduled tasks and send an email notification if a scheduled task does not complete successfully. This is for Windows 2003 server.
Thanks. Wendy
Here are a couple of options:
- Check the ErrorLevel of each command executed by your scheduled task, then use blat.exe (downloadable from many sites) do generate a notification EMail to yourself.
- Use the Task Scheduler to run this batch file once every few hours:
01. @echo off
02. for /F "delims=" %%a in ('schtasks /query /v /fo:list ^| findstr /i
"Taskname Result"') do call :Sub %%a
03. goto :eof
04.
05. :Sub
06. set Line=%*
07. set BOL=%Line:~0,4%
08. set MOL=%Line:~38%
09. if /i %BOL%==Task (
10. set name=%MOL%
11. goto :eof
12. )
13. set result=%MOL%
14. echo Task Name=%name%, Task Result=%result%
15. if not %result%==0 (
16. echo Task %name% failed
17. echo blat.exe .. .. ..
18. )
You can also try using Task Scheduler. You can find some options in the below link. This tool will help you to get the kind of output you are looking for. It is a bit easy to configure any automated things using Task. Because you can configure it in the graphical way. I am not very use to using scripts. Most of the they do not work. I had tried using them many times but it failed. Later on I started using Task with different kind of settings and it worked. There is no issue at all. You can try checking details of below link. There are more relative information available on it.
Run a Task in Response to a Given Event
The following link can help you. This link is based on configuring task through script. A sample script is also provided on the same. You have to go through the link and try to understand how it works. You can then configure it as per your need. In the same link there are more topics like WMI Tasks for Scripts and Applications. Where more advance topics are configured. MSDN is the best source to locate information on various things. I always keep on checking new articles here. WMI Tasks for Scripts and Applications is complete guide to manage task with various things.
WMI Tasks: Scheduled Tasks
Bookmarks