Task Scheduler runs programs and scripts automatically — at a time, at startup, at logon, or when an event happens. On a Windows server it replaces cron: backups, cleanup scripts, report generation, application restarts.
Open it with Win + R → taskschd.msc.
Create a task (the right way)
Use Create Task… (not Create Basic Task) to get all options.
General tab
- Name and description.
- Run whether user is logged on or not — essential on servers; otherwise the task only runs while you’re signed in.
- Run with highest privileges — if the script needs administrator rights.
- Configure for: your Windows version.
- Choose the account: a dedicated service account is better than your personal admin account.
SYSTEMworks for local maintenance tasks that don’t need network credentials.
Triggers tab
- On a schedule — daily, weekly, monthly, with Repeat task every for intervals (e.g. every 15 minutes).
- At startup — run after the server boots (add a short delay).
- At log on, On idle, On an event — e.g. run a script when a specific Event ID is logged.
Actions tab
For a PowerShell script:
- Program/script:
powershell.exe - Arguments:
-NoProfile -ExecutionPolicy Bypass -File "C:\Scripts\backup.ps1" - Start in:
C:\Scripts
Conditions tab
On servers, untick Start the task only if the computer is on AC power (sometimes ticked by default) and idle conditions you don’t want.
Settings tab
- Allow task to be run on demand — for testing.
- Run task as soon as possible after a scheduled start is missed — catches up after downtime.
- Stop the task if it runs longer than — a sensible limit.
- If the task is already running: Do not start a new instance.
Create the same task with PowerShell
$action = New-ScheduledTaskAction -Execute "powershell.exe" `
-Argument '-NoProfile -ExecutionPolicy Bypass -File "C:\Scripts\backup.ps1"' `
-WorkingDirectory "C:\Scripts"
$trigger = New-ScheduledTaskTrigger -Daily -At 3:15am
$settings = New-ScheduledTaskSettingsSet -StartWhenAvailable -ExecutionTimeLimit (New-TimeSpan -Hours 2) `
-MultipleInstances IgnoreNew
Register-ScheduledTask -TaskName "Nightly backup" -Action $action -Trigger $trigger `
-Settings $settings -User "SYSTEM" -RunLevel Highest
Run it now and check the result:
Start-ScheduledTask -TaskName "Nightly backup"
Get-ScheduledTaskInfo -TaskName "Nightly backup" | Select LastRunTime, LastTaskResult, NextRunTime
LastTaskResult of 0 means success.
Write scripts that work unattended
- Use full paths — scheduled tasks don’t start in your usual folder.
- Don’t rely on mapped drive letters; use UNC paths (
\\server\share). - Log to a file so you can see what happened:
Start-Transcript -Path "C:\Scripts\logs\backup-$(Get-Date -Format yyyyMMdd).log"
# … work …
Stop-Transcript
- Exit with a non-zero code on failure (
exit 1) so Task Scheduler records the error.
Troubleshooting
| Result / symptom | Likely cause |
|---|---|
0x1 |
The script itself returned an error — check its log; often a wrong path or permissions |
0x41301 |
Task is currently running |
0x800710E0 |
Operator or administrator refused the request — usually conditions (power/idle) or a policy |
| Runs manually, not on schedule | Run only when user is logged on selected, or the trigger is disabled/expired |
| Works for you, fails as task | Different account: missing network access, profile or permissions |
Enable History (Action menu → Enable All Tasks History) to see each run’s events.
Good uses on a Windows VPS
- Nightly backups of application data to off-server storage
- Cleaning old logs and temporary files
- Restarting a trading terminal or app every morning
- Sending a daily health report
Pair it with event logging for auditing. Our Windows VPS and Forex VPS pages cover running always-on Windows workloads.