Some tasks nobody should do by hand: a nightly backup, cleaning a downloads folder or running a script when the PC starts. Windows Task Scheduler does it for you, even with no one signed in. Here you will see how to create a well-configured task, how to do it from the command line and how to find out why a task “does nothing”.
In short
- Each task has triggers (when), actions (what), conditions and settings (when it runs or not).
- For scripts use Create Task, not Create Basic Task: it gives access to privileges, run account and conditions.
- If it does not run, check the last run result and enable history, which is off by default.
Open Task Scheduler
Press Windows + R, type taskschd.msc and press Enter. You can also search “Task Scheduler” in the Start menu.
The window has three areas: on the left, the Task Scheduler Library with folders; in the middle, the tasks in the selected folder; on the right, the Actions pane. Windows and many programs keep their tasks in subfolders like Microsoft\Windows. Do not touch those; create your own folder (right-click the Library > New Folder) to keep yours together.
The four parts of a task

| Tab | Defines | Example |
|---|---|---|
| Triggers | When it starts | Every day at 02:00 |
| Actions | What it runs | powershell.exe with a script |
| Conditions | Machine requirements | Only on AC power |
| Settings | Behavior on failure | Retry, stop if too long |
The General tab adds two key things: which account runs it and with what privileges.
Available triggers
- On a schedule: once, daily, weekly or monthly, with optional repetition (for example, every 15 minutes for 12 hours).
- At log on: of any user or a specific one.
- At startup: before anyone signs in.
- On idle: when the computer has been unused a while.
- On an event: when a specific event appears in Event Viewer.
- On workstation lock or unlock, and on remote session connect or disconnect.
A task can have several triggers; any one is enough.
Create a task for a script, step by step
Say you have a PowerShell script at C:\Scripts\copia.ps1 you want to run every night.
- In the right pane click Create Task (not “Create Basic Task”).
- Under General, give it a clear name, such as
Nightly backup. - Choose Run whether user is logged on or not. Saving asks for the account password.
- Tick Run with highest privileges if the script needs admin rights.
- Under Triggers, click New, choose On a schedule, Daily and the time.
- Under Actions, click New and fill in:
- Program/script:
powershell.exe - Add arguments:
-NoProfile -ExecutionPolicy Bypass -File "C:\Scripts\copia.ps1" - Start in:
C:\Scripts
- Program/script:
- Under Conditions, on a laptop, untick Start the task only if the computer is on AC power if it should also work on battery.
- Under Settings, tick Run task as soon as possible after a scheduled start is missed. If the PC was off at 02:00, it runs when turned on.
- Click OK, enter the password and test with right-click > Run.
For a .bat, put the file path directly in Program/script and the folder in Start in.
Why “Start in” matters
Left empty, the task starts in a system working folder, usually C:\Windows\System32. Any relative path in the script (a config.ini, a log.txt) points there and fails. Always fill “Start in” or use absolute paths in the script.

Which account and privileges

| Option | What happens | When to use it |
|---|---|---|
| Run only when user is logged on | The window is visible; needs an open session | Programs with an interface, user notices |
| Run whether user is logged on or not | Runs in background, no visible window | Scripts and backups |
| Do not store password | No password prompt, but local resources only | Scripts that do not touch the network |
SYSTEM account | Maximum local rights, no password | Maintenance of the machine itself |
| Highest privileges | Runs elevated, no UAC prompt | Scripts requiring admin |
Two surprising consequences:
- With “whether logged on or not” you will see nothing on screen. If the script waits for a key press, it waits forever.
- Mapped network drives (like
Z:) do not exist in that context. Use UNC paths like\\NAS\Backups.
Create tasks from the command line with schtasks
schtasks lets you create, query and delete tasks from a script, handy for setting up identical machines. Run it in an administrator console.
Create a daily task at 02:00 with the SYSTEM account and elevated privileges:
schtasks /create /tn "My tasks\Nightly backup" /tr "C:\Scripts\copia.bat" /sc daily /st 02:00 /ru SYSTEM /rl highest
Other common examples:
rem Every 30 minutes
schtasks /create /tn "My tasks\Sync" /tr "C:\Scripts\sync.bat" /sc minute /mo 30
rem Monday and Friday at 18:00
schtasks /create /tn "My tasks\Report" /tr "C:\Scripts\informe.bat" /sc weekly /d MON,FRI /st 18:00
rem At system startup
schtasks /create /tn "My tasks\Startup" /tr "C:\Scripts\arranque.bat" /sc onstart /ru SYSTEM
| Parameter | Purpose |
|---|---|
/tn | Task name, with folder if you like |
/tr | Program or script to run |
/sc | Frequency: minute, hourly, daily, weekly, monthly, once, onstart, onlogon, onidle, onevent |
/mo | Modifier: every how many minutes, hours, days… |
/st | Start time in HH:mm |
/ru | Account that runs it |
/rl highest | Highest privileges |
Manage existing tasks:
schtasks /query /tn "My tasks\Nightly backup" /v /fo list
schtasks /run /tn "My tasks\Nightly backup"
schtasks /change /tn "My tasks\Nightly backup" /disable
schtasks /delete /tn "My tasks\Nightly backup" /f
If the script path has spaces, you need escaped quotes inside /tr: /tr "\"C:\My scripts\copia.bat\"". It is the most common cause of schtasks tasks that cannot find the file.
PowerShell offers cmdlets, more readable for complex tasks:
$accion = New-ScheduledTaskAction -Execute "powershell.exe" -Argument '-NoProfile -ExecutionPolicy Bypass -File "C:\Scripts\copia.ps1"' -WorkingDirectory "C:\Scripts"
$disparador = New-ScheduledTaskTrigger -Daily -At 2am
Register-ScheduledTask -TaskName "Nightly backup" -TaskPath "\My tasks\" -Action $accion -Trigger $disparador -User "SYSTEM" -RunLevel Highest
History and why a task does not run
Enable history
By default the Scheduler keeps no history. In the right pane, with the Library selected, click Enable All Tasks History. From then on each task’s History tab shows when it was triggered, when the action started and how it ended.
Those events are in Event Viewer under Applications and Services Logs > Microsoft > Windows > TaskScheduler > Operational.
Read the last run result
The Last Run Result column gives a code. The most frequent:
| Code | Meaning | What to check |
|---|---|---|
0x0 | Finished successfully | If it still did nothing, the problem is in the script |
0x1 | The program returned an error | Script path, “Start in”, permissions, or a program returning 1 without failing |
0x2 | File not found | Program path or misplaced quotes |
0x41301 | Task is running | May be hung waiting for input |
0x41303 | Has not run yet | Trigger not met |
0x41306 | Task was terminated | Stopped by a user or time limit |
Beware 0x1: some programs return 1 without failure. Robocopy, for example, returns 1 when it copied files successfully. In those cases the task code is not enough; check the program’s own log.
PowerShell shows the same:
Get-ScheduledTaskInfo -TaskName "Nightly backup" -TaskPath "\My tasks\"
Debugging trick
Make the script write its own output to a file. Change the action to something like:
cmd.exe /c "C:\Scripts\copia.bat > C:\Scripts\copia-log.txt 2>&1"
That way you see the real error message, which you would never read in a windowless task.
Common mistakes
- Empty “Start in” and relative paths in the script pointing to
System32. - Laptop on battery with the AC power condition on: the task is silently skipped.
- Mapped drive letters in a task running without session. Use UNC paths.
- Changing the account password without updating the task: it stops with a logon error. Edit the task and re-enter it.
- Scripts asking for confirmation or pausing: in the background they never end.
- PowerShell script execution blocked. Pass
-ExecutionPolicy Bypassin arguments instead of changing the machine policy. - PC off or asleep at the scheduled time and the run-ASAP option unticked.



