schtasks - Task Scheduler
“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]
| Parameter | Description |
|---|---|
/TN | Task name |
/TR | Path of the program or batch file to run |
/SC | Schedule type (DAILY, WEEKLY, ONCE, etc.) |
/ST | Start time (HH:MM) |
/SD | Start date (in the OS short-date format, e.g. MM/DD/YYYY on en-US) |
/MO | Interval or modifier (the 3 in “every 3 days”) |
/D | Day of the week or month (WEEKLY and MONTHLY) |
/RU | User account that runs the task |
/RL | Run level (HIGHEST for administrator rights) |
/F | Overwrite a task of the same name without a warning |
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
| Type | Description |
|---|---|
MINUTE | Run every specified number of minutes |
HOURLY | Run every specified number of hours |
DAILY | Run every day or every specified number of days |
WEEKLY | Run on specified days of the week |
MONTHLY | Run on a specified day of the month |
ONCE | Run only once |
ONSTART | Run at system startup |
ONLOGON | Run at logon |
ONIDLE | Run 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
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
| Day | Meaning |
|---|---|
MON | Monday |
TUE | Tuesday |
WED | Wednesday |
THU | Thursday |
FRI | Friday |
SAT | Saturday |
SUN | Sunday |
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
/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

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

60分でわかる! 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
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
Creating or deleting tasks with schtasks may require administrator rights. If you see “Access is denied”, start the command prompt as administrator.
Summary
| Task | Command |
|---|---|
| Create a task | schtasks /create /tn "name" /tr "path" /sc type /st time |
| List tasks | schtasks /query |
| Delete a task | schtasks /delete /tn "name" /f |
| Run a task | schtasks /run /tn "name" |
| Stop a task | schtasks /end /tn "name" |
| Disable a task | schtasks /change /tn "name" /disable |