schtasks - Task Scheduler

Maintained on

“I want to run a backup every night” or “I want a script to run when the PC starts” are common needs in real work.

The schtasks command lets you operate Windows Task Scheduler from the command line and schedule batch files or programs.

Create a task (/CREATE)

Basic syntax

SCHTASKS /CREATE /TN "task name" /TR "command to run" /SC schedule_type [options]
ParameterDescription
/TNTask name
/TRPath of the program or batch file to run
/SCSchedule type (DAILY, WEEKLY, ONCE, etc.)
/STStart time (HH:MM)
/SDStart date (in the OS short-date format, e.g. MM/DD/YYYY on en-US)
/MOInterval or modifier (the 3 in “every 3 days”)
/DDay of the week or month (WEEKLY and MONTHLY)
/RUUser account that runs the task
/RLRun level (HIGHEST for administrator rights)
/FOverwrite a task of the same name without a warning
Date and time formats depend on the OS regional settings

The date format for /SD and similar options can vary with the Windows regional settings. If you get an error, check the format shown by schtasks /create /?.

Schedule types

TypeDescription
MINUTERun every specified number of minutes
HOURLYRun every specified number of hours
DAILYRun every day or every specified number of days
WEEKLYRun on specified days of the week
MONTHLYRun on a specified day of the month
ONCERun only once
ONSTARTRun at system startup
ONLOGONRun at logon
ONIDLERun when idle (/I with the idle time in minutes is required)

Run every day at a set time

schtasks /create /tn "DailyBackup" /tr "C:\Scripts\backup.cmd" /sc daily /st 23:00
- □ ×
Command Prompt Icon
Command Prompt
Microsoft Windows [Version xx.x.xxxxx.xxx]
(c) 2026 Ribbit App Development All rights reserved.
 
C:\users\user>schtasks /create /tn "DailyBackup" /tr "C:\Scripts\backup.cmd" /sc daily /st 23:00
SUCCESS: The scheduled task “DailyBackup” has successfully been created.
C:\users\user>

Run every few days

Use /MO to set the interval.

schtasks /create /tn "CleanupTask" /tr "C:\Scripts\cleanup.cmd" /sc daily /mo 3 /st 02:00

Run every few minutes or hours

MINUTE and HOURLY take their interval from /MO.

schtasks /create /tn "HealthCheck" /tr "C:\Scripts\check.cmd" /sc minute /mo 30
schtasks /create /tn "SyncTask" /tr "C:\Scripts\sync.cmd" /sc hourly /mo 2

Run on specific days of the week

Use /D to specify the days.

schtasks /create /tn "WeeklyReport" /tr "C:\Scripts\report.cmd" /sc weekly /d MON,FRI /st 09:00
DayMeaning
MONMonday
TUETuesday
WEDWednesday
THUThursday
FRIFriday
SATSaturday
SUNSunday

Run on a specific day of the month

Use /SC MONTHLY with /D to set the day.

schtasks /create /tn "MonthlyJob" /tr "C:\Scripts\monthly.cmd" /sc monthly /d 1 /st 06:00

Specify a path that contains spaces

If the path in /TR contains spaces, wrap it in \" to escape the quotes. Otherwise everything before the first space is treated as the program name and the task will not run.

schtasks /create /tn "MyTask" /tr "\"C:\My Scripts\backup.cmd\"" /sc daily /st 23:00

Run at startup or logon

At system startup

schtasks /create /tn "StartupScript" /tr "C:\Scripts\startup.cmd" /sc onstart /ru SYSTEM

At logon

schtasks /create /tn "LoginScript" /tr "C:\Scripts\login.cmd" /sc onlogon
About the /RU option

/RU sets the user account that runs the task. With SYSTEM, the task runs even when no user is logged on. If you omit /RU, the task is registered for the user who ran the command and runs only while that user is logged on. Registering a task as SYSTEM requires administrator rights.

For tasks that perform operations requiring administrator rights, add /RL HIGHEST when you register them.

Run only once

rem The date format shown is for en-US; adapt it to your regional settings
schtasks /create /tn "OneTimeTask" /tr "C:\Scripts\migrate.cmd" /sc once /st 03:00 /sd 03/15/2027

Show registered tasks (/QUERY)

schtasks /query /tn "DailyBackup" /fo list
- □ ×
Command Prompt Icon
Command Prompt
Microsoft Windows [Version xx.x.xxxxx.xxx]
(c) 2026 Ribbit App Development All rights reserved.
 
C:\users\user>schtasks /query /tn "DailyBackup" /fo list
Folder: \
HostName: DESKTOP-USER
TaskName: \DailyBackup
Next Run Time: 3/11/2026 11:00:00 PM
Status: Ready
C:\users\user>
おすすめ書籍※ 広告を含む場合があります
中小企業経営者のためのRPA入門 RPA導入を成功させる方法

中小企業経営者のためのRPA入門 RPA導入を成功させる方法

60分でわかる! AIエージェント 超入門

60分でわかる! AIエージェント 超入門

コマンドラインの黒い画面が怖いんです。

コマンドラインの黒い画面が怖いんです。

知識・才能ゼロでもらく~に月10万円稼ぐ! よくわかるAI副業超入門

知識・才能ゼロでもらく~に月10万円稼ぐ! よくわかるAI副業超入門

Show all tasks

schtasks /query /fo table

Output as CSV

schtasks /query /fo csv > tasks.csv

To see details such as the command being run and the last result, add /V.

schtasks /query /tn "DailyBackup" /v /fo list
チェック

Use /FO to choose the output format: TABLE, LIST or CSV.

Delete a task (/DELETE)

schtasks /delete /tn "DailyBackup" /f
- □ ×
Command Prompt Icon
Command Prompt
Microsoft Windows [Version xx.x.xxxxx.xxx]
(c) 2026 Ribbit App Development All rights reserved.
 
C:\users\user>schtasks /delete /tn "DailyBackup" /f
SUCCESS: The scheduled task “DailyBackup” was successfully deleted.
C:\users\user>

With /F, the task is deleted without a confirmation prompt.

Disable or change a task (/CHANGE)

To stop a task temporarily without deleting it, disable it with /CHANGE. Use /ENABLE to turn it back on.

schtasks /change /tn "DailyBackup" /disable
schtasks /change /tn "DailyBackup" /enable

Run a task manually (/RUN)

To run a registered task immediately, use /RUN.

schtasks /run /tn "DailyBackup"

Stop a running task (/END)

To stop a task that is running, use /END.

schtasks /end /tn "DailyBackup"

Practical example: automating a backup

This example creates a backup batch file and registers it with Task Scheduler.

@echo off
setlocal

rem Where to create the backup script
set SCRIPT_PATH=C:\Scripts\daily_backup.cmd

if not exist "D:\Backup\Logs" mkdir "D:\Backup\Logs"

rem Create the backup script
echo @echo off > "%SCRIPT_PATH%"
echo robocopy "C:\Users\user\Documents" "D:\Backup\Documents" /MIR /R:3 /W:5 /LOG+:"D:\Backup\Logs\backup.log" /NP >> "%SCRIPT_PATH%"

rem Register it with Task Scheduler
schtasks /create /tn "AutoBackup" /tr "%SCRIPT_PATH%" /sc daily /st 23:00 /f

echo Setup complete.
echo The backup will run automatically every day at 23:00.

endlocal
About administrator rights

Creating or deleting tasks with schtasks may require administrator rights. If you see “Access is denied”, start the command prompt as administrator.

Summary

TaskCommand
Create a taskschtasks /create /tn "name" /tr "path" /sc type /st time
List tasksschtasks /query
Delete a taskschtasks /delete /tn "name" /f
Run a taskschtasks /run /tn "name"
Stop a taskschtasks /end /tn "name"
Disable a taskschtasks /change /tn "name" /disable

Practice question

Practice Problem

Which value of the /SC option runs a batch file when a user logs on to the PC?

回答がサーバーに送信されることはありません
#Command Prompt #Batch Files #Command Line #Commands