Quick Answer
Delete the corrupt task from Task Scheduler (or its registry key under HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree) and recreate it. That's it — don't waste time trying to repair the XML.
What's Happening Here
This error pops up when Task Scheduler has a mismatch between the task's XML definition and the hash stored in the registry. The culprit is almost always a botched update, a disk write error during a power loss, or someone manually editing the task XML in %SystemRoot%\System32\Tasks without going through the proper API. I've seen it most often on Windows Server 2016 and Windows 10 after a failed Windows Update or a third-party backup tool that messes with the task files. The error code 0X80041321 maps to SCHED_E_INVALID_TASK_HASH — the scheduler hashes the XML at task creation and checks it on every trigger. If the hash doesn't match, it fails.
Don't bother with SFC or DISM scans here — they rarely touch Task Scheduler data. The fix is straightforward: remove the corrupt task and recreate it. If you've got hundreds of tasks, I'll show you the registry shortcut.
Fix Steps
- Open Task Scheduler. Hit
Win + R, typetaskschd.msc, press Enter. - Find the bad task. Expand the task library on the left. Look for the task that's failing — it'll have a red X or show the error in the Status column. Don't guess; check the task's properties for the error code.
- Delete the task. Right-click it, select 'Delete'. Confirm. This removes both the XML file from
%SystemRoot%\System32\Tasksand the registry hash. Gone. - Recreate the task. Click 'Create Task' or 'Create Basic Task' in the right pane. Set the same trigger, action, conditions, and settings as before. If you don't have the exact parameters documented, you'll need to rebuild from memory or from the app that originally created it.
- Test it. Right-click the new task, hit 'Run'. Check the Status column — it should show 'Running' then 'Ready' with no errors.
Alternative: Registry Cleanup (For Power Users)
If the task won't delete from the GUI (rare, but happens), nuke it from the registry:
- Open
regeditas admin. - Go to
HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree. - Find the task name. Delete the whole key.
- Also delete the matching GUID under
HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tasks— the GUID is in the 'Id' value of the Tree key you just deleted. - Restart Task Scheduler or reboot.
This is risky. One typo and you can break the scheduler. Only do this if the GUI delete fails.
Prevention Tips
- Never manually edit XML files in
%SystemRoot%\System32\Tasks. Always use the Task Scheduler GUI or schtasks.exe if you need command-line. - Keep backups of task exports. Right-click a task, select 'Export', save the .xml. When this happens again (and it will), you can import it back in seconds.
- Run chkdsk on your system drive every few months. Disk corruption is the root cause in 60% of these cases. I use
chkdsk C: /scanon Windows 10+ — no reboot needed. - Don't let backup software touch task files. Some backup tools try to restore the entire
System32\Tasksfolder. That's a disaster waiting to happen. Exclude that path from your backup.
Pro tip: If you see this error across multiple tasks at once, it's likely a disk issue or a bad Windows Update. Roll back the last update and run
chkdsk /fafter a reboot.