Windows scheduled task fails to complete with error code 0xc000013a
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?
Solution 1:
Troubleshooting scheduled scripts:
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.-
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 calledftp.data.cmd
then your scheduled task might look like this,cmd /c ftp.data.cmd >> ftp.data.log 2>&1
-
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%
Are you sure the account running the script has permissions / access to everything in the script?
-
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
Solution 2:
I can't answer the question directly as I don't know specifically what the error message means (nor, therefore, how to fix it), but if I were trying to troubleshoot it I would add a few writes to a log file at strategic points in the script and then after the scheduled time see what the last checkpoint to run is.
My suspicion would be that there's something that's failing due to the credentials the script is running under or something in the script needs a logged-in user. Narrowing down where in the script things fail might help you find the "offending" code.
Solution 3:
I realize this is an old posting but they're very helpful when searching for solutions and maybe what I found can be helpful too. I was using WinSCP on Windows Server 2003 to upload to an ftp server and received the same error message and the SchedLgU.txt file pointed to not enough time in the "Stop the task if it furn for:" section even though I gave the task plenty of time to upload.
Looking in Task Manager I could see that WinSCP.exe wasn't clearing out and I had tons of the processes in the list, so I created a batch file (taskkill /f /im winscp.exe) to kill any opened process and I have that batch file run before the WinSCP and it works well now.
Solution 4:
I ran into this today on a remote server, and the solution was to change the run setting from "Run only when the user is logged on" to "Run whether the user is logged in or not".
With "Run only when the user is logged on" the task launches a command window that was closed when my remote desktop session timed out. With "Run whether the user is logged in or not" no window is displayed while the task runs, so the execution does not stop when my remote desktop session ends.