Schedule tasks with Windows Task Scheduler
Create scheduled tasks in Task Scheduler or PowerShell, choose the right account and trigger, and fix tasks that do not run.
- Intermediate
- Windows VPS · Admin RDP
- 2 min read
Task Scheduler runs programs and scripts for you: at startup, at a set time, or when a user signs in. It is the Windows answer to cron and the usual way to automate backups, clean-ups and restarts of your own tools.
Create a task with the graphical tool
- Press Windows + R, type
taskschd.mscand press Enter. - Click Create Task (not "Create Basic Task", which hides useful options).
- General: give it a name. Choose Run whether user is logged on or not for scripts that need no window, and tick Run with highest privileges if the script needs admin rights.
- Triggers → New: for example Daily at 03:00, or At startup.
- Actions → New: Start a program. For a PowerShell script, program
powershell.exeand arguments-NoProfile -ExecutionPolicy Bypass -File "C:\Scripts\cleanup.ps1". - Settings: tick If the task fails, restart every 5 minutes if it should retry.
- Click OK and enter the account password when asked.
Create the same task in PowerShell
$action = New-ScheduledTaskAction -Execute "powershell.exe" -Argument '-NoProfile -ExecutionPolicy Bypass -File "C:\Scripts\cleanup.ps1"'
$trigger = New-ScheduledTaskTrigger -Daily -At 3am
Register-ScheduledTask -TaskName "Nightly cleanup" -Action $action -Trigger $trigger -User "SYSTEM" -RunLevel HighestRun it once now to test, and see the result:
Start-ScheduledTask -TaskName "Nightly cleanup"
Get-ScheduledTaskInfo -TaskName "Nightly cleanup" | Select-Object LastRunTime, LastTaskResultA LastTaskResult of 0 means success.
Tasks set to run whether the user is logged on or not, or running as SYSTEM, have no visible desktop. Programs with a window, such as MetaTrader or a browser, will not appear. For those, use an At log on trigger and Run only when user is logged on, as shown in Auto-start MetaTrader after a reboot.
Good uses
- Copy important folders to a backup location every night (backup guide).
- Delete log files older than 30 days.
- Restart a service that occasionally hangs.
Troubleshooting
- Task says it ran but nothing happened: the script probably uses relative paths. Use full paths, or set Start in on the action.
- Result 0x1: the script itself returned an error. Run the same command by hand in PowerShell to see the message.
- Task never starts: check the History tab (enable it with Enable All Tasks History in the right panel).
Next steps
Was this guide helpful?
Still stuck?
Ask RunRacks AI for a quick answer, or open a ticket and our team will take a look at your server.
Related guides
Windows VPS & RDP
RunRacks RDP port 12230: how to connect to your Windows VPS and Admin RDP
RunRacks Windows VPS and Admin RDP servers accept Remote Desktop on port 12230, not 3389. Here is how to connect from every device and keep the port open.
- Beginner
- Windows VPS · Admin RDP
- 5 min read
Windows VPS & RDP
Allow or block multiple RDP sessions for one user
Understand why a new Remote Desktop login takes over your old session, how the single-session policy works on Windows Server, and which setting suits a team.
- Advanced
- Windows VPS
- 5 min read
Windows VPS & RDP
Create Windows users with Remote Desktop access
Give each person their own Windows login, add them to Remote Desktop Users, test the account and remove access cleanly later.
- Beginner
- Windows VPS · Admin RDP
- 2 min read