Create a scheduled task from CMD with schtasks
Register a recurring Windows task entirely from the command line — ideal for scripts, cleanup jobs, and monitoring probes you want to run unattended.
01Command
$ schtasks /Create /TN "WeeklyDiskCleanup" /TR "cleanmgr /sagerun:1" /SC WEEKLY /D SUN /ST 02:0002What it does
The /TN switch is the unique task name (use a folder prefix like `MyCompany\Backup` to group tasks), /TR is the exact command line, and /SC sets the schedule: MINUTE, HOURLY, DAILY, WEEKLY, ONSTART, ONLOGON, and more. Add `/RU SYSTEM` to run as Local System or `/RU domain\user /RP password` for a specific account. Verify with `schtasks /Query /TN "Name" /V` or the Task Scheduler GUI, and test the payload with `schtasks /Run /TN "Name"`. If the task writes files, give it an absolute working directory or it will default to system32.
03Risk
04Undo
$ schtasks /Delete /TN "WeeklyDiskCleanup" /F05Sources
- schtasks | Microsoft LearnEvidence: Microsoft documents schtasks /Create with the /TN, /TR, /SC, /D and /ST parameters for scheduling commands to run at a specified time and interval.
- Schedule tasks - schtasks - Windows CMDEvidence: SS64 lists schtasks schedules including MINUTE, HOURLY, DAILY, WEEKLY and ONLOGON with syntax examples for each.
Last verified: 2026-09-17 · Category: System & Settings
06Related solutions
Use the System File Checker to verify every protected Windows system file against known-good copies and automatically replace the damaged ones.
Use Windows Package Manager to install, search, and upgrade thousands of applications from the community repository in one command.
Robocopy is Windows' built-in robust file copier: use /MIR to keep a destination folder as an exact one-way mirror of a source, resumable and restartable.