Solved

Windows batch and task schedular

Posted on 2013-01-03
7
405 Views
Last Modified: 2013-01-04
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
0
Comment
Question by:Evan Cutler
  • 3
  • 3
7 Comments
 
LVL 29

Expert Comment

by:becraig
ID: 38741913
Depending on the nature of the file you can write an easy text log append:
Task run on Date at time and was successful


ECHO Batch file return code: %ERRORLEVEL% >> %dir%\Taskrun.log
0
 
LVL 9

Author Comment

by:Evan Cutler
ID: 38741942
ok..so your saying that you can or cannot append the status in the tasks themselves with a error??

Sorry, new territory for me.
0
 
LVL 29

Expert Comment

by:becraig
ID: 38741983
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:

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
0
Don't lose your head updating email signatures!

Do your end users still have the wrong email signature? Do email signature updates bore you or fill you with a sense of dread? You can make this a whole lot easier on yourself by trusting an Exclaimer email signature management solution. Over 50 million users do...so should you!

 
LVL 9

Author Comment

by:Evan Cutler
ID: 38742011
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?status
I can't put a defined message into that block?  but I can put in a specified error into the (0x0) block, yes?
0
 
LVL 29

Expert Comment

by:becraig
ID: 38742056
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
0
 
LVL 25

Accepted Solution

by:
Tony Giangreco earned 500 total points
ID: 38742353
I agree, that return code is from the O/S. Writing a log file would be the quickest and easiest to implement.
0
 
LVL 9

Author Closing Comment

by:Evan Cutler
ID: 38745093
Thanks for helping...I'll have to go another route then...my application is weird, and not mine...thanks
0

Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

You may have already been in the need to update a whole folder stucture using a script. Robocopy does it well and even provides a list of non-updated files in a log (if asked to). Generally those files that were locked by a user or a process by the …
A procedure for exporting installed hotfix details of remote computers using powershell
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles to another domain controller. Log onto the new domain controller with a user account t…
This tutorial will show how to configure a single USB drive with a separate folder for each day of the week. This will allow each of the backups to be kept separate preventing the previous day’s backup from being overwritten. The USB drive must be s…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now