Thursday, May 20, 2010

Run Exe's in Windows 2008 Task Scheduler

I had a requirement where I needed to run a program as a scheduled task. I configured the program but it wasn't firing the exe at all. At last I figured out that I cannot execute an EXE via Task Scheduler and used a batch script to wrap the EXE call and scheduled it in Task Scheduler.

@echo off
echo %date% %time% Start of task > c:\temp\test.log
echo User=%UserName%, Path=%path% >> c:\temp\test.log
c:\Tools\Task.exe 1>>c:\temp\test.log 2> c:\temp\test.err
echo ErrorLevel of c:\Tools\YourTask.exe=%ErrorLevel% >> c:\temp\test.log
echo %date% %time% End of task >> c:\temp\test.log

No comments:

Post a Comment