Evan Cutler
asked on
Windows batch and task schedular
Greetings...
I have a windows task to automatically run a batch file.
I have no problems there.
When it runs successfully, the status is blank and the code is 0x0...
I was wondering...is there something I can put into the batch to tell the task that executed it something? like putting "I ran good", or a specified error in the status of the task that called it?
Thanks
I have a windows task to automatically run a batch file.
I have no problems there.
When it runs successfully, the status is blank and the code is 0x0...
I was wondering...is there something I can put into the batch to tell the task that executed it something? like putting "I ran good", or a specified error in the status of the task that called it?
Thanks
ASKER
ok..so your saying that you can or cannot append the status in the tasks themselves with a error??
Sorry, new territory for me.
Sorry, new territory for me.
You can put this in a bat file
The idea is ErrorLevel gets reported on the previous command
the following statement
If %ErrorLevel% == 0
means if the command did not report an error then the exit code is 0
At this point you can simply echo the error level to a file using a re-director to append
ECHO Batch file return code: %ERRORLEVEL% >> %dir%\Taskrun.log
The above should answer your question:
adding a link to explain error level:
http://blogs.msdn.com/b/oldnewthing/archive/2008/09/26/8965755.aspx
The idea is ErrorLevel gets reported on the previous command
the following statement
If %ErrorLevel% == 0
means if the command did not report an error then the exit code is 0
At this point you can simply echo the error level to a file using a re-director to append
ECHO Batch file return code: %ERRORLEVEL% >> %dir%\Taskrun.log
The above should answer your question:
I was wondering...is there something I can put into the batch to tell the task that executed it something? like putting "I ran good", or a specified error in the status of the task that called it?
adding a link to explain error level:
http://blogs.msdn.com/b/oldnewthing/archive/2008/09/26/8965755.aspx
ASKER
ok...so you can report back the error level of the task...
but the actual error would have to go to a file or some other place? (ie. the Taskrun.log)
it cannot be re-sent back to the task schedular to the space marked by the attached image?
I can't put a defined message into that block? but I can put in a specified error into the (0x0) block, yes?
but the actual error would have to go to a file or some other place? (ie. the Taskrun.log)
it cannot be re-sent back to the task schedular to the space marked by the attached image?
I can't put a defined message into that block? but I can put in a specified error into the (0x0) block, yes?
Not to my knowledge that is task scheduler native return codes to help you find out why the "task" did not run if it fails also this is generally logged on the local computer in a log file, usually something like C:\Windows\Tasks\xxx.txt
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for helping...I'll have to go another route then...my application is weird, and not mine...thanks
Task run on Date at time and was successful
ECHO Batch file return code: %ERRORLEVEL% >> %dir%\Taskrun.log