Windows scheduled task fails to complete with error code 0xc000013a

scheduled-taskwindowswindows-server-2003

I'm using Windows Server 2003 and have a scheduled task that fails to complete. The task is set to run a Windows Command Script (.cmd) at 3pm each day. The script runs a program that extracts some data from a SQL Server database and uploads that data to an FTP server.

The error code displayed in the "Last result" column of the scheduled tasks folder is 0xc000013a. A quick Google search leads to this Microsoft support page that states: The most common "C" error code is "0xC000013A: The application terminated as a result of a CTRL+C".

No-one is logged in at the time the task runs, so there's no-one around to press CTRL+C. I'm not sure I understand what is being said here in the Microsoft documentation.

I've checked the rudimentary things – the scheduled task is enabled, scheduled to run each day, and pointing to a file that does exist in a valid location. Interestingly, when I run this task manually (either by running the .cmd script from the command line, or by right-clicking the task and clicking "Run") the task completes successfully.

What does this error code mean, and how can I get this task to run when I'm not there to force it?

Best Answer

Troubleshooting scheduled scripts:

  1. If you haven't already, check the Scheduled Tasks log file, in the GUI under Advanced > View Log. Search the file for "***" to find the most recent entries, and you may see a little extra error info.

  2. Define a log file to capture output, and send both standard out and standard error there. Change any echo OFF to echo ON to be sure you're not supressing any error messages.
    For example, if your script is called ftp.data.cmd then your scheduled task might look like this,

    cmd /c ftp.data.cmd >> ftp.data.log 2>&1

  3. Is the script hanging? Maybe the task scheduler is killing the script (hence the CTRL+C error code) after some specified period of time. Add some of these at strategic points in your scipt,

    echo %DATE% %TIME%

  4. Are you sure the account running the script has permissions / access to everything in the script?

  5. If you can't get any joy, run this command and post the output here, maybe we can start with the scheduling,

    schtasks /query /v /fo LIST /s YOURSERVER