Flash Sale:75% Off Hosting + Free DomainEnds in13h47m14sView Plans
Hostvento logoHostvento

How to Set Up a Cron Job on Windows

Windows has no cron, but Task Scheduler and PowerShell do the same job.

Windows Hosting2 min read6 steps6 screenshots

Windows does not have cron. The tool for scheduled tasks is Task Scheduler. You can also create tasks with PowerShell.

Method 1: Task Scheduler

  1. Press Win + R, type the following and press Enter:
taskschd.msc
Opening Task Scheduler with the Run dialog
  1. Click Create Basic Task on the right.
    Creating a basic task
  2. Enter a name and a description for the task.
    Naming the task
  3. Choose the trigger: daily, weekly, monthly, one time, at startup or at logon. Then set the time.
    Choosing the task trigger
  4. Choose the action Start a program. Click Browse and pick the program or script, for example notepad.exe or your .bat or .ps1 file. In Add arguments type any options.
    Choosing the program to run
  5. Click Finish.
    The task created

Right-click the task and choose Run to test it. In the task properties, tick Run whether user is logged on or not and Run with highest privileges for server jobs.

Method 2: PowerShell

$action = New-ScheduledTaskAction -Execute "cmd.exe" -Argument "/c your_command.exe"
$trigger = New-ScheduledTaskTrigger -Daily -At 00:00
$principal = New-ScheduledTaskPrincipal -UserId "SYSTEM" -RunLevel Highest
Register-ScheduledTask -TaskName "YourTaskName" -Action $action -Trigger $trigger -Principal $principal

Run PowerShell as administrator. List and remove tasks:

Get-ScheduledTask -TaskName "YourTaskName"
Unregister-ScheduledTask -TaskName "YourTaskName" -Confirm:$false

Method 3: schtasks

schtasks /create /tn "BackupJob" /tr "C:\scripts\backup.bat" /sc daily /st 02:00

Third-party tools

If you want the real Linux cron syntax, use Windows Subsystem for Linux (WSL) and run cron there. Other schedulers with more options exist too. Pick a tool based on how complex your tasks are.

Best practices

  • Test the command by hand first.
  • Use full paths to programs and scripts.
  • Write the output to a log file.
  • Run important tasks with a service account and the least rights needed.
  • Check the History tab if a task does not run.

Quick recap

  • Use Task Scheduler (taskschd.msc), schtasks or PowerShell.