Fix Windows Task Scheduler 'Last Run Result 0x1' โ€” Task Not Running

intermediate๐ŸชŸ Windows2026-05-04| Windows 10, Windows 11, Windows Server 2016/2019/2022 โ€” Task Scheduler (taskschd.msc)

Error Message

Task Scheduler: Last Run Result 0x1 (0x41301 - Task Is Currently Running)
#windows#task-scheduler#automation#cron

TL;DR

0x1 = your task's program exited with a non-zero exit code (generic failure). 0x41301 = the task is still running โ€” or hung from a previous run. Quick checklist:

  • Run the command manually in CMD first. If it fails there, fix the command โ€” not the scheduler.
  • Set "Start in" to the folder where your script lives.
  • Check "Run whether user is logged on or not" + "Run with highest privileges".
  • For 0x41301: kill the hung instance and configure a stop timeout.

What These Codes Actually Mean

Task Scheduler doesn't generate 0x1 itself โ€” it just forwards whatever exit code your program returned. Exit code 1 is basically every language's universal "something broke" signal. Python uses it. Bash uses it. Even batch scripts default to it. That's why 0x1 tells you nothing specific; you have to look at the program itself.

0x41301 is a different beast. It's an internal Task Scheduler code meaning the task is already running. This happens when a previous instance didn't finish before the next trigger fired โ€” a backup job that takes 90 minutes but runs every hour, for example.

Step 1 โ€” Reproduce the Failure Manually

Before touching Task Scheduler settings, open CMD as the same user the task runs as and run the exact command. Nine times out of ten, the error shows up right there.

# If your task runs a PowerShell script:
powershell.exe -ExecutionPolicy Bypass -File "C:\Scripts\backup.ps1"

# Check the exit code right after:
echo %ERRORLEVEL%

Non-zero ERRORLEVEL? The script is broken. Fix the script first โ€” the scheduler is just the messenger.

Step 2 โ€” Fix the "Start In" Directory

This single setting accounts for roughly 40% of 0x1 cases. Scripts that use relative paths (./config.json, ../logs/) break silently when Task Scheduler launches them from C:\Windows\System32.

Go to Task Scheduler โ†’ right-click your task โ†’ Properties โ†’ Actions tab โ†’ Edit action:

  • Program/script: powershell.exe (or full path to your exe)
  • Arguments: -ExecutionPolicy Bypass -File "C:\Scripts\backup.ps1"
  • Start in (optional): C:\Scripts โ† point this at your script's directory

Step 3 โ€” Fix Permissions and User Context

Tasks running "only when user is logged on" inherit your desktop session. Run them in the background and they get a stripped-down token โ€” no desktop, limited access. Here's what to fix:

  • General tab โ†’ select "Run whether user is logged on or not"
  • Check "Run with highest privileges" if the task needs admin rights
  • Enter credentials when prompted โ€” Task Scheduler encrypts and stores them

One more trap: if the task touches network shares, don't run it as SYSTEM. The SYSTEM account has no network credentials. Use a domain service account that actually has access to those paths.

Step 4 โ€” Enable Logging to See the Real Error

Redirect output to a log file. Without this you're guessing.

<!-- In your task's Action โ†’ Arguments: -->
-ExecutionPolicy Bypass -File "C:\Scripts\backup.ps1" >> "C:\Logs\backup.log" 2>&1

<!-- Or wrap it in cmd.exe for cleaner redirection: -->
cmd.exe /c "powershell.exe -File C:\Scripts\backup.ps1 >> C:\Logs\backup.log 2>&1"

Also flip on the Task Scheduler operational log in Event Viewer โ€” it's off by default:

# Applications and Services Logs โ†’ Microsoft โ†’ Windows โ†’ TaskScheduler โ†’ Operational
# Right-click โ†’ Enable Log

# Or one-liner in PowerShell:
wevtutil set-log Microsoft-Windows-TaskScheduler/Operational /enabled:true

After the next run, look for event ID 201 (completed) or 203/101 (failed with reason). Event 101 especially gives you the actual error message.

Fixing 0x41301 โ€” Hung Instance

A previous run got stuck. Kill it, then set up guardrails so it doesn't pile up again.

# Find running task instances:
Get-ScheduledTask | Where-Object {$_.State -eq 'Running'}

# Stop a specific task:
Stop-ScheduledTask -TaskName "YourTaskName" -TaskPath "\YourFolder\"

# Or via schtasks:
schtasks /end /tn "\YourFolder\YourTaskName"

Then open task Properties โ†’ Settings tab:

  • "If the task is already running..." โ†’ set to "Stop the existing instance" or "Do not start a new instance"
  • "Stop the task if it runs longer than" โ†’ set a hard timeout. For most jobs, 1โ€“2 hours is plenty.

PowerShell Scripts โ€” Exit Codes Matter

A PowerShell script that ends without an explicit exit returns the last command's status code. If that last command failed โ€” even a Write-Host that hit a locked file โ€” you get 0x1. Be explicit:

try {
    # ... your work ...
    Write-Host "Done"
    exit 0
} catch {
    Write-Error $_.Exception.Message
    exit 1  # intentional failure
}

Also check execution policy. PowerShell can silently block a script without printing anything useful:

# See what's set at each scope:
Get-ExecutionPolicy -List

# Always pass -ExecutionPolicy Bypass in the task action:
powershell.exe -ExecutionPolicy Bypass -NonInteractive -File "C:\Scripts\run.ps1"

Quick Diagnostic via schtasks

# Last run result for every task on the machine:
schtasks /query /fo LIST /v | findstr /i "last run result"

# Drill into one specific task:
schtasks /query /tn "\MyFolder\MyTask" /fo LIST /v

# Trigger it right now for testing:
schtasks /run /tn "\MyFolder\MyTask"

Verify the Fix

  • Right-click the task โ†’ Run
  • Refresh Task Scheduler โ€” Last Run Result should show 0x0
  • Open your log file and confirm actual output
  • Event Viewer โ†’ TaskScheduler/Operational โ†’ event ID 201, result 0
# Quick check from PowerShell:
(Get-ScheduledTaskInfo -TaskName "YourTaskName").LastTaskResult
# Should return: 0

Common Causes at a Glance

  • Wrong working directory โ€” relative paths fail when launched from System32
  • Missing permissions โ€” needs admin rights or network access it doesn't have
  • Broken script โ€” exits non-zero, Task Scheduler just reports it faithfully
  • Execution policy โ€” PowerShell silently blocks the script
  • Hung previous instance (0x41301) โ€” no timeout, instances pile up
  • Missing dependencies โ€” script calls Python, Node, or another tool that isn't installed

Related Error Notes