Return code 2147942401 from Task Scheduler corresponds to an “Access is denied” (0x80070005) error. After installing the latest Windows Server 2022 updates, scheduled tasks that previously worked can start failing with this code if permissions, elevation, or policy requirements are not met.
To resolve this, use the following checks and fixes:
- Run Task Scheduler elevated
- Right-click Task Scheduler and select Run as administrator.
- Re-run the task manually and confirm whether it still returns 2147942401.
- Verify the account and its permissions
- In Task Scheduler, right-click the failing task → Properties → General.
- Confirm When running the task, use the following user account is set to an account that:
- Still exists and is not disabled.
- Has local permissions to run the program/script and access any required files/paths.
- If the task must perform admin-level actions, ensure the account is in the Administrators group or otherwise has the required rights.
- Enable “Run with highest privileges”
- In the same General tab, select Run with highest privileges.
- This ensures the task runs elevated, which is often required after security-hardening updates.
- Check “Log on as a batch job” right (Group Policy)
- Open gpedit.msc.
- Go to Computer Configuration → Windows Settings → Security Settings → Local Policies → User Rights Assignment.
- Open Log on as a batch job and verify the task’s run-as account is listed (or included via a group that is listed).
- If not, add it, apply the policy, and then retry the task.
- Re-register the task if it may be corrupted
- Export the task, delete it, and re-import it to refresh its registration:
- From an elevated PowerShell prompt:
Export-ScheduledTask -TaskName "<task_name>" -FilePath "C:\Temp\<task_name>.xml" - Delete the task in Task Scheduler.
- After any file/registry corrections, re-register it:
Register-ScheduledTask -Xml (Get-Content "C:\Temp\<task_name>.xml" | Out-String) -TaskName "<task_name>"
- Use History and Last Run Result for further detail
- In Task Scheduler, select the task and check:
- Last Run Result (should show 0x0 when successful).
- History tab for any additional error events that indicate which resource or action is being denied.
- In Task Scheduler, select the task and check:
If the task still fails with 2147942401 after these steps, focus on what the task actually runs (script, EXE, or command) and test that command directly in an elevated PowerShell or Command Prompt under the same account to see where access is denied.
References: