Ran into a problem today with using a scheduled task which was not executing properly after changes being made to it’s batchjob. Ofcourse the Windows Task Scheduler doesn’t give a very good description on the error message so I found a nice article that uses the following code:
echo %date% %time% Start of task > c:\test.log
echo User=%UserName%, Path=%path% >> c:\test.log
c:\Tools\YourTask.exe 1>>c:\test.log 2>c:\test.err
echo ErrorLevel of c:\Tools\YourTask.exe=%ErrorLevel% >> c:\test.log
echo %date% %time% End of task >> c:\test.log
Using this code to run the application produced very nice debugging results for us to work on a solution.
I found this code via http://forums.techarena.in/windows-server-help/419821.htm but it seems to be a rather common knowledge item.