Task Scheduler Last Run Result 0x0, but the script failed
Windows Task Scheduler shows Last Run Result: The operation completed successfully. (0x0), yet the export is empty or the report wasn't refreshed. 0x0 means less than it seems, it lies for three common reasons, and the real result is easy to report.
What 0x0 actually means
Task Scheduler starts a program and waits for the number it returns when it ends, its exit code. 0x0 is that number in hexadecimal: 0, which by convention means success. 0x1 means the program returned 1, which is usually a generic error. A few values are Task Scheduler's own: 0x41301 the task is still running, 0x41303 it has not run yet (Microsoft lists them as Task Scheduler error and success constants).
So 0x0 doesn't say "the job worked". It says "the program I started returned 0". Three things make that different from what you wanted to know:
- A wrapper hides the code. A
.batfile ends with the errorlevel that is set when it finishes, usually that of its last command. If the real job fails and a latercopyorechosucceeds, the batch file ends with 0. Only an explicitexit /b %ERRORLEVEL%right after the job passes the failure on. - The program returns 0 after an error. Stata in batch mode does this, so do many in-house tools, and a PowerShell script with non-terminating errors does too (see PowerShell exit codes).
- The job "worked" but did nothing useful. A query that returns no rows, a source file from yesterday, an API that answered with an empty list: all exit with 0.
And when the task doesn't run at all, there is no new result: the column keeps showing the last one, which may well be 0x0.
Report the real result
The most reliable fix is to report from inside the job, in its own language: Python, R, Stata and the others send /fail with the error message themselves. When you can't change the program, wrap it. The batch file below starts your job, keeps its exit code, and reports it to TaskBeacon at the end of the ping address: /0 is OK, any other number a failure, sent with the last 20 lines of output.
@echo off
REM Save as C:\jobs\taskbeacon-run.bat
REM Task Scheduler > Action: Start a program
REM Program: C:\jobs\taskbeacon-run.bat
REM Runs your job, then reports success or failure from its exit code.
set "TB=https://taskbeacon.io/ping/your-job-id"
curl.exe -fsS -m 10 "%TB%/start" >nul
REM --- your job here (a program, a script, another .bat with call): replace the path ---
REM its output goes to a temporary file: shown below, and its last 20 lines go with a failure
set "TB_LOG=%TEMP%\taskbeacon-%RANDOM%.log"
call "C:\path\to\your-job.bat" > "%TB_LOG%" 2>&1
set TB_RC=%ERRORLEVEL%
type "%TB_LOG%"
type nul > "%TB_LOG%.tail"
if not "%TB_RC%"=="0" powershell.exe -NoProfile -Command "Get-Content -LiteralPath $env:TB_LOG -Tail 20 | ForEach-Object { if ($_.Length -gt 300) { $_.Substring(0, 300) } else { $_ } }" > "%TB_LOG%.tail" 2>nul
REM the exit code goes at the end of the address: /0 = OK, any other number = failed
curl.exe -fsS -m 10 --data-binary "@%TB_LOG%.tail" -H "Content-Type: text/plain" "%TB%/%TB_RC%" >nul
del "%TB_LOG%" "%TB_LOG%.tail" 2>nul
exit /b %TB_RC%In the app, the Code tab of your job gives you this code with the job's own address instead of your-job-id, and you can untick the parts you don't need.
In Task Scheduler, point the task's action at this .bat instead of your job. Because it ends with exit /b %TB_RC%, the Last Run Result now matches what TaskBeacon shows. If you prefer PowerShell, the PowerShell wrapper does the same for any .exe.
What you get
- Failed with the exit code and the last lines of output, by email or in Slack or Teams, the moment the job ends.
- Missed when the task didn't run by its planned time plus grace: the case where Task Scheduler just keeps showing yesterday's 0x0.
- Late when the job started and is taking much longer than usual.
For the "worked but did nothing" case, an exit code is not enough: the job has to send a number such as the row count. See 0 rows or far fewer than usual.
Without TaskBeacon
Fix the wrapper: end every batch file with exit /b %ERRORLEVEL% right after the step that matters, and make your programs return a non-zero code on failure. Then check the Last Run Result column, or enable the task history and look for the task's events in Event Viewer. That makes the failure visible, but only to someone who looks; for a notification see email when a scheduled task fails.
Connected Claude or ChatGPT to TaskBeacon? Ask it "what failed last night, and why?" and it answers from your jobs. How that works.
Related
In the Docs: Batch (.bat) · PowerShell (Task Scheduler) · Exit code in the ping.
- Task Scheduler can't send email any more: get an alert when a task failsThe built-in e-mail action is gone; event-triggered tasks miss runs that never happened.
- PowerShell script errors and the exit code in Task SchedulerNon-terminating errors leave exit code 0; -Command squashes codes to 0 or 1.
- Get an alert when a Stata do-file fails in batch modeStata /e and -b don't report a failed do-file to the scheduler.
TaskBeacon is free to start, with every feature open for now and no credit card. Create a job, paste the code, and the first ping shows up on the job page.
Start free View live demoSources
- Microsoft Learn: Task Scheduler error and success constants (0x41301, 0x41303 …) (2024-10-29)
- Microsoft Learn: the exit command (exit /b sets the errorlevel) (2023-10-12)
- Microsoft Q&A: How to fix (0x1) error in task scheduler that runs a python script (2023-08-28, old: a sign of demand)
- Stack Overflow: Getting Windows Task Scheduler to show failure for run result (2015, old: a sign of demand)
Page checked against its sources on 2026-11-19. Menus and limits of other products change; if something here no longer matches, write to support@taskbeacon.io.