On Microsoft Windows’, cron jobs are known as Scheduled Tasks. They can be added through the Windows Task Scheduler user interface, by using PowerShell or with help of schtasks.exe.

Running a task at specific time or at recurring dates is one of the common administrative tasks on all operating systems. On Linux, the tool cron is used for this purpose. Microsoft Windows’ counterpart for cron is the Scheduled Task.

Each Scheduled Task is planned by the Task Scheduler. This application has been available since Windows NT 4.0, known as Task Scheduler 1.0. On modern Windows systems (Windows Server 2016, 2019, Windows 10 etc.), the Task Scheduler is available in version 2.0.

How to add a scheduled task

There are multiple way, how recurring tasks can be added on Windows.

The following three methods require that you are logged in with an administrative account. Make sure that you have access to an account with administrative permissions!

Using the Task Scheduler

You can open the Windows Task Scheduler by either

  • clicking on Start and typing Task Scheduler
  • or hitting Win+R and typing taskschd.msc

If you don’t have administrative permission, you can hit Win+R and type

runas /user:${ADMIN} taskschd.msc

${ADMIN} must be replaced with your administrator’s account username.

In both cases, the following Microsoft Management Console (MMC) will open

Task Scheduler MMC
Task Scheduler MMC

In the right screen click on Create Basic Task

Create Basic Task
Create Basic Task

The now opening window cotains is a wizard. You can specify when a specific application has to be executed.

  1. On the first screen, type a name and description of your new cron job
  2. You can select the Trigger on the second screen. A trigger means when a specific task has to be executed.
    Select a trigger
    You can choose between
    • Daily
    • Weekly
    • Monthly
    • One time
    • When the computer starts (before you have logged on)
    • When I log on
    • When a specific event is logged
  3. On the Action tab you can specify which command has to be executed. Specify a path to the .exe or .bat file and click on Next
    Task Wizard: Action
  4. On the last screen you see all information about the task. Click on Finish to add it.

The new scheduled task is automatically activated. It will be started when the next specified trigger is hit.

Using the command line tool schtasks.exe

You can also add the new scheduled tasks by using the command line. This is handy if you already have a batch file to automate something. For more complex or dynamic task definitions, you might want to use the PowerShell method below.

On Windows, you can use schtasks.exe to create, delete or modify scheduled tasks. To use schtasks.exe, start a new command line as an administrator by hitting Win+R and type cmd.exe. Everything you can do with the Microsoft Management Console can be done with schtasks.exe.

Please take a look at Microsofts official documentation for all available options.

Argument Description
/Create Add a new scheduled task
/tnName of task
/scschedule frequency (MINUTE, HOURLY, DAILY and so on)
/dOn which day or day of month the task shall be scheduled. You can use * for scheduling on every day
/stStart time in format HH:mm
/trApplication to run, e.g. cmd.exe

To add a new task, you can use the following code

schtasks.exe /create /tn my-task /sc daily  /st 13:00 /tr cmd.exe

This would execute the cmd.exe every day on 13:00. The task automatically appears in the Task Scheduler MMC:

Task added with schtasks.exe
Task added with schtasks.exe

Using PowerShell

You can also add new cron jobs with help of PowerShell. This can be handy if you need to programatically add tasks on a lot of machines.

Start a new PowerShell by hitting Win+R and type powershell. You need the following three commands to add a new task:

$action = New-ScheduledTaskAction -Execute 'cmd.exe'
$trigger = New-ScheduledTaskTrigger -Daily -At 1pm
Register-ScheduledTask -Action $action -Trigger $trigger -TaskName "my-task"
Task added with PowerShell

The following video shows you how you can add a cron job with help of PowerShell.

Frequently asked questions

Where are Windows scheduled tasks stored?

This one might come in handy if you are debugging scheduled tasks or jobs. In some cases, your task is not executed due to some quoting or escaping issues.

Windows stores scheduled jobs and tasks in the following locations als XML files:

Type Location Info
Task%WINDIR%\System32\TasksStored as XML file
Job $home\AppData\Local\Microsoft\Windows\PowerShell\ScheduledJobs Stored as XML file but not the same as the Task XML file definition

Does cron work on Windows?

If you are familiar with Linux, you can also make use of the Linux cron service inside the Windows Subsystem for Linux. One problem at the moment is, that cron only works during the lifetime of the WSL session. As soon as the WSL session is closed, cron will also be closed.

You should use one of methods above to add a cron job on Windows.

Are “scheduled jobs” and “scheduled tasks” in PowerShell are the same?

If you are creating new scheduled tasks with help of PowerShell you might find this interesting. In PowerShell there do exists scheduled tasks but also scheduled jobs. The New-ScheduledTask* cmdlets are just a frontend for schtasks.exe and the Scheduled Task MMC.

Scheduled tasks have one big drawback: You can’t capture the output of the executed command. But with scheduled jobs you can grab the output. I’d like to refer to this article if you need more details.

I am asking you for a donation...

You liked the content or this article has helped and reduced the amount of time you have struggled with this issue? Please donate a few bucks so I can keep going with my troubleshooting adventure :-)

Categories: Windows