The command: "SCHTASKS /Create /?" is on Windows 12, 11, 10, .. , MS Server 2025, 2022, 2019, .. available
The examples for the command "SCHTASKS /Create /?"
Here are examples of using the
`SCHTASKS /Create` command to create a scheduled task:
Example 1: Create a simple scheduled task:
SCHTASKS /Create /SC DAILY /TN "MyTask" /TR "C:\Path\To\Script.bat" /ST 12:00
This command creates a daily scheduled task named
"MyTask" that runs the batch script
"C:\Path\To\Script.bat" every day at 12:00 p.m.
Example 2: Create a scheduled task with specific credentials:
SCHTASKS /Create /SC WEEKLY /D MON /TN "Weekly Report" /TR "C:\Path\To\Report.exe" /ST 08:00 /RU "Username" /RP "Password"
Here, a weekly scheduled task called
"Weekly Report" is created that runs the program
"C:\Path\To\Report.exe" every Monday at 8:00 a.m. The credentials (
`username` and
`password`) are specified.
Example 3: Create a scheduled task on a remote computer:
SCHTASKS /Create /S "RemoteComputer" /U "AdminUser" /P "AdminPassword" /SC MONTHLY /D 15 /TN "Monthly Report" /TR "C:\Path\To\MonthlyReport.exe" /ST 18:00
Here a monthly scheduled task named Monthly Report is created on the remote computer RemoteComputer. The task runs the program
"C:\Path\To\MonthlyReport.exe" on the 15th of each month at 6:00 p.m. The credentials for execution on the remote computer are specified.
Hints:
- The parameters like
`/SC` (Schedule),
`/TN` (Task Name),
`/TR` (Task Run),
`/ST` (Start Time),
`/RU` (Run As User),
` /RP` (Run As Password) may vary depending on specific requirements. Use
`SCHTASKS/?` for a complete list of options and parameters.
- Make sure you have sufficient permissions to create scheduled tasks, especially if you provide credentials.
- Credentials should be handled carefully to comply with security guidelines.
"SCHTASKS /Create /?" Excerpt from Microsoft Windows Help
Microsoft Windows [Version 10.0.19045.3693]
(c) Copyright 1985-2023 Microsoft Corp.
C:\\WINDOWS>
SCHTASKS /Create [/S system [/U username [/P password]]]
[/RU username [/RP password]] /SC schedule [/MO modifier] [/D day]
[/I idletime] /TN taskname /TR taskrun [/ST starttime] [/M months]
[/SD startdate] [/ED enddate]
Description:
Enables an administrator to create scheduled tasks on a local or
remote systems.
Parameter List:
/S system Specifies the remote system to
connect to. If omitted the system
parameter defaults to the local
system.
/U username Specifies the user context under
which the command should execute.
/P password Specifies the password for the given
user context.
/RU username Specifies the user account (user
context) under which the task runs.
For the system account, valid values
are "", "NT AUTHORITY\SYSTEM" or
"SYSTEM".
/RP password Specifies the password for the user.
To prompt for the password, the value
must be either "*" or none.
Password will not effect for the
system account.
/SC schedule Specifies the schedule frequency.
Valid schedule types: MINUTE, HOURLY,
DAILY, WEEKLY, MONTHLY, ONCE,
ONSTART, ONLOGON, ONIDLE.
/MO modifier Refines the schedule type to allow
finer control over schedule
recurrence. Valid values are listed
in the "Modifiers" section below.
/D days Specifies the day of the week to run
the task. Valid values: MON, TUE,
WED, THU, FRI, SAT, SUN and for
MONTHLY schedules 1 - 31 (days of the
month).
/M months Specifies month(s) of the year.
Defaults to the first day of the
month. Valid values: JAN, FEB, MAR,
APR, MAY, JUN, JUL, AUG, SEP, OCT,
NOV, DEC.
/I idletime Specifies the amount of idle time to
wait before running a scheduled
ONIDLE task.
Valid range: 1 - 999 minutes.
/TN taskname Specifies a name which uniquely
identifies this scheduled task.
/TR taskrun Specifies the path and file name of
the program to be run by this
scheduled task.
Example: C:\windows\system32\calc.exe
/ST starttime Specifies the time to run the task.
The time format is HH:MM:SS (24 hour
time) for example, 14:30:00 for
2:30 PM.
/SD startdate Specifies the first date on which the
task runs. The format is
"mm/dd/yyyy".
/ED enddate Specifies the last date when the task
should run. The format is
"mm/dd/yyyy".
/? Displays this help/usage.
Modifiers: Valid values for the /MO switch per schedule type:
MINUTE: 1 - 1439 minutes.
HOURLY: 1 - 23 hours.
DAILY: 1 - 365 days.
WEEKLY: weeks 1 - 52.
ONCE: No modifiers.
ONSTART: No modifiers.
ONLOGON: No modifiers.
ONIDLE: No modifiers.
MONTHLY: 1 - 12, or
FIRST, SECOND, THIRD, FOURTH, LAST, LASTDAY.
Examples:
SCHTASKS /Create /S system /U user /P password /RU runasuser
/RP runaspassword /SC HOURLY /TN rtest1 /TR notepad
SCHTASKS /Create /S system /U domain\user /P password /SC MINUTE
/MO 5 /TN rtest2 /TR calc.exe /ST 12:00:00
/SD 10/20/2001 /ED 10/20/2001 /RU runasuser /RP
SCHTASKS /Create /SC MONTHLY /MO first /D SUN /TN game
/TR c:\windows\system32\freecell
SCHTASKS /Create /S system /U user /P password /RU runasuser
/RP runaspassword /SC WEEKLY /TN test1 /TR notepad.exe
SCHTASKS /Create /S system /U domain\user /P password /SC MINUTE
/MO 5 /TN test2 /TR c:\windows\system32\notepad.exe
/ST 18:30:00 /RU runasuser /RP *
SCHTASKS /Create /SC MONTHLY /MO first /D SUN /TN cell
/TR c:\windows\system32\freecell /RU runasuser
Important information, tips for the "SCHTASKS /Create /?" command
There are some important considerations and points to note when using the `SCHTASKS /Create` command:
### Permissions:
1. Task logging: Check the logs of your scheduled tasks to ensure they are running properly. This can be helpful in identifying problems.
2. Periodic Check: Regularly check your scheduled tasks, especially after system updates or changes, to ensure they are working properly.
3. Time Format: Make sure the times and schedules are formatted correctly. Incorrect time specifications can lead to unexpected behavior.
4. Parameter combinations: Some parameters are related to each other. Make sure the combination of parameters makes sense and produces the desired results.
5. Time vs. Time Interval: Note the difference between specifying a specific time (`/ST`) and a time interval (`/ET`). Clarify what type of schedule is appropriate for your planned task.
6. Scheduled task permissions: Make sure that the user executing `SCHTASKS /Create` has the required permissions for the scheduled task. In particular, if you specify credentials (`/RU` and `/RP`), these users must have the necessary permissions.
7. Understanding the parameters: Take the time to read the documentation (`SCHTASKS /?`) to understand the various parameters and their effects.
8. Admin Rights: Creating scheduled tasks requires administrator rights. Make sure you open Command Prompt as an administrator.
9. Program or script dependencies: If your scheduled task depends on external programs or scripts, ensure that the environment variables, paths and dependencies are configured properly.
10. Backup of Tasks: If necessary, create backups of your scheduled task configuration for quick restore in the event of a problem.
It is important to use the `SCHTASKS /Create` command carefully, especially when used on production systems. Unwanted changes to scheduled tasks can result in unexpected behavior.