Every night a
task runs that checks if any scheduled
task has a Last Result is not equal to 0x0. If a scheduled tasks has an error like 0x1, then automatically an e-mail is sent to me. As some tasks are running only weekly, and sometimes an error occurs which results in not equal to 0x0, every night an e-mail is sent with the error message, as the Last Result column still shows the last result of 0x1. But I would like to set the Last Result column to 0x0 manually if I solved a problem, so I won't get every night an e-mail with the error message.
So is it possible to set the scheduled tasks Last Result to 0x0 manually (or by a script)?
@harrymc. See located script underneath that is sending the e-mail. I can easily add a criteria to ignore result 0x1 (or another code), however this is not the solution as most of the times this result is a real error and has to be e-mailed.
set
[email protected]
set SMTPServer=SMTPserver
set PathToScript=c:\scripts
set
[email protected]
for /F "delims=" %%a in ('schtasks /query /v /fo:list ^| findstr /i "Taskname Result"') do call :Sub %%a
goto :eof
:Sub
set Line=%*
set BOL=%Line:~0,4%
set MOL=%Line:~38%
if /i %BOL%==Task (
set name=%MOL%
goto :eof
)
set result=%MOL%
echo
Task Name=%name%,
Task Result=%result%
if not %result%==0 (
echo
Task %name% failed with result %result% > %PathToScript%\taskcheckerlog.txt
bmail %PathToScript%\taskcheckerlog.txt -t %YourEmailAddress% -a "Warning! Failed %name% Scheduled
Task on %computername%" -s %SMTPServer% -f %FromAddress% -b "
Task %name% failed with result %result% on CorVu scheduler %computername%"
)