Schedule Task Error Codes

Discussion in 'Windows Server' started by Miller, Mar 20, 2007.

  1. Miller

    Miller Guest

    I run a number of simple batch jobs each night to copy backup data to a
    server, last week two of the jobs that had been working fine suddenly started
    to fail, the task scheduler log files states the task completed with an exit
    code of (4). What I need to know is what that code means; I have done a lot
    of internet searches for this information but can't find anything for this
    exit code.

    If I run the batch file manually it runs fine, it is only when executed via
    scheduled tasks that it fails.
    Miller, Mar 20, 2007
    1. Advertisements

  2. The answer is far simpler than you think: The error codes
    are not generated by the Task Scheduler but by the copy
    command. Expand your batch file as per the example
    below, then examine the file c:\test.log and everything will
    immediately become clear:

    @echo off
    echo %date% %time% Start of task > c:\test.log
    echo User=%UserName%, Path=%path% >> c:\test.log
    net use >> c:\test.log
    copy .. .. .. .. 1>>c:\test.log 2>>&1
    echo ErrorLevel of the copy command=%ErrorLevel% >> c:\test.log
    echo %date% %time% End of task >> c:\test.log
    Pegasus \(MVP\), Mar 20, 2007
    1. Advertisements

  3. Miller

    Miller Guest

    Sorted it - thanks

    Miller, Mar 20, 2007
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.