Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Windows scheduled task allows administrator to create a recurrent job on a device, with the command SCHTASKS.


...

Command Exemples

Create a scheduled task that runs everyday at 09:00 AM (starts today)

SCHTASKS /CREATE /SC DAILY /TN "'The name of my scheduled task'" /TR "'C:\Users\Admin\Documents\Scripts\ScriptToRun.vbs'" /ST 09:00

Delete a task (without a confirmation prompt)

SCHTASKS /DELETE /TN "'The name of my scheduled task'" /F


Warning
titlequote in parameters

Every parameters with quotes should be quoted with double quotes " " on the outside and single quote ' ' on the inside. Otherwise, white spaces inside your parameter values might be wrongly interpreted.

...

Integration within the proVConnect console

1) Use the launch command

On your provconnect manager, open the command list menu, choose a Launch command and type your SCHTASKS command exactly like you would type it in the windows command prompt.

Image Added

2) Save your task

Click on the Save As button and save your task, so you can reload and use it as many time as you want. You can create a category for your task. On the image below, the category is called scheduled task.

Image Added

3) Publish your task

You finally need to publish your task on your devices.

Image Added


...


List of Parameters for SchTasks (from the microsoft documentation)

/sc <ScheduleType>
Schedule typeDescription
MINUTE, HOURLY, DAILY, WEEKLY, MONTHLYSpecifies the time unit for the schedule.
ONCEThe task runs once at a specified date and time.
ONSTARTThe task runs every time the system starts. You can specify a start date, or run the task the next time the system starts.
ONLOGONThe task runs whenever a user (any user) logs on. You can specify a date, or run the task the next time the user logs on.
ONIDLEThe task runs whenever the system is idle for a specified period of time. You can specify a date, or run the task the next time the system is idle.
/tn <TaskName>

Specifies a name for the task. Each task on the system must have a unique name. The name must conform to the rules for file names and must not exceed 238 characters. Use quotation marks to enclose names that include spaces.

/tr <TaskRun>

Specifies the program or command that the task runs. Type the fully qualified path and file name of an executable file, script file, or batch file. The path name must not exceed 262 characters. If you omit the path, schtasks assumes that the file is in the SystemRoot\System32 directory.

/s <Computer>

Schedules a task on the specified remote computer. Type the name or IP address of a remote computer (with or without backslashes). The default is the local computer. The /u and /p parameters are valid only when you use /s.

/u [<Domain>]

Runs this command with the permissions of the specified user account. The default is the permissions of the current user of the local computer. The /u and /p parameters are valid only for scheduling a task on a remote computer (/s).

The permissions of the specified account are used to schedule the task and to run the task. To run the task with the permissions of a different user, use the /ru parameter.

The user account must be a member of the Administrators group on the remote computer. Also, the local computer must be in the same domain as the remote computer, or must be in a domain that is trusted by the remote computer domain.

/p <Password>

Provides the password for the user account specified in the /u parameter. If you use the /u parameter, but omit the /p parameter or the password argument, schtasks prompts you for a password and obscures the text you type.

The /u and /p parameters are valid only for scheduling a task on a remote computer (/s).

/ru {[<Domain>] | System}

Runs the task with permissions of the specified user account. By default, the task runs with the permissions of the current user of the local computer, or with the permission of the user specified by the /u parameter, if one is included. The /ru parameter is valid when scheduling tasks on local or remote computers.

/RU {[<DOMAIN>] | SYSTEM}

ValueDescription
[<Domain>]Specifies an alternate user account.
System orSpecifies the local System account, a highly privileged account used by the operating system and system services.
/rp <Password>

Provides the password for the user account that is specified in the /ru parameter. If you omit this parameter when specifying a user account, SchTasks.exe prompts you for the password and obscures the text you type.

Do not use the /rp parameter for tasks run with System account credentials (/ru System). The System account does not have a password and SchTasks.exe does not prompt for one.

/mo <Modifier>

Specifies how often the task runs within its schedule type. This parameter is valid, but optional, for a MINUTE, HOURLY, DAILY, WEEKLY, and MONTHLY schedule. The default value is 1.

/MO <MODIFIER>

Schedule typeModifier valuesDescription
MINUTE1 - 1439The task runs every <N> minutes.
HOURLY1 - 23The task runs every <N> hours.
DAILY1 - 365The task runs every <N> days.
WEEKLY1 - 52The task runs every <N> weeks.
ONCENo modifiers.The task runs once.
ONSTARTNo modifiers.The task runs at startup.
ONLOGONNo modifiers.The task runs when the user specified by the /u parameter logs on.
ONIDLENo modifiers.The task runs after the system is idle for the number of minutes specified by the /i parameter, which is required for use with ONIDLE.
MONTHLY1 - 12The task runs every <N> months.
MONTHLYLASTDAYThe task runs on the last day of the month.
MONTHLYFIRST, SECOND, THIRD, FOURTH, LASTUse with the /d<Day> parameter to run a task on a particular week and day. For example, on the third Wednesday of the month.
/d Day[,Day...] | *

Specifies a day (or days) of the week or a day (or days) of a month. Valid only with a WEEKLY or MONTHLY schedule.

/D DAY[,DAY...] | *

Schedule typeModifierDay values (/d)Description
WEEKLY1 - 52MON - SUN[,MON - SUN...]*
MONTHLYFIRST, SECOND, THIRD, FOURTH, LASTMON - SUNRequired for a specific week schedule.
MONTHLYNone or {1 - 12}1 - 31Optional and valid only with no modifier (/mo) parameter (a specific date schedule) or when the /mo is 1 - 12 (an every <N> months schedule). The default is day 1 (the first day of the month).
/m Month[,Month...]

Specifies a month or months of the year during which the scheduled task should run. Valid values are JAN - DEC and * (every month). The /m parameter is valid only with a MONTHLY schedule. It is required when the LASTDAY modifier is used. Otherwise, it is optional and the default value is * (every month).

/i <IdleTime>

Specifies how many minutes the computer is idle before the task starts. A valid value is a whole number from 1 to 999. This parameter is valid only with an ONIDLE schedule, and then it is required.

/st <StartTime>

Specifies the time of day that the task starts (each time it starts) in <HH:MM> 24-hour format. The default value is the current time on the local computer. The /st parameter is valid with MINUTE, HOURLY, DAILY, WEEKLY, MONTHLY, and ONCE schedules. It is required for a ONCE schedule.

/ri <Interval>

Specifies the repetition interval in minutes. This is not applicable for schedule types: MINUTE, HOURLY, ONSTART, ONLOGON, and ONIDLE. Valid range is 1 to 599940 minutes (599940 minutes = 9999 hours). If either /ET or /DU is specified, then the repetition interval defaults to 10 minutes.

/et <EndTime>

Specifies the time of day that a minute or hourly task schedule ends in <HH:MM> 24-hour format. After the specified end time, schtasks does not start the task again until the start time recurs. By default, task schedules have no end time. This parameter is optional and valid only with a MINUTE or HOURLY schedule.

For an example, see:

  • To schedule a task that runs every 100 minutes during non-business hours in the To schedule a task that runs every <N> minutes section.
/du <Duration>

Specifies a maximum length of time for a minute or hourly schedule in <HHHH:MM> 24-hour format. After the specified time elapses, schtasks does not start the task again until the start time recurs. By default, task schedules have no maximum duration. This parameter is optional and valid only with a MINUTE or HOURLY schedule.

For an example, see:

  • To schedule a task that runs every 3 hours for 10 hours in the To schedule a task that runs every <N> hours section.
/k

Stops the program that the task runs at the time specified by /et or /du. Without /k, schtasks does not start the program again after it reaches the time specified by /et or /du, but it does not stop the program if it is still running. This parameter is optional and valid only with a MINUTE or HOURLY schedule.

For an example, see:

  • To schedule a task that runs every 100 minutes during non-business hours in the To schedule a task that runs every <N> minutes section.
/sd <StartDate>

Specifies the date on which the task schedule starts. The default value is the current date on the local computer. The /sd parameter is valid and optional for all schedule types.

The format for StartDate varies with the locale selected for the local computer in Regional and Language Options in Control Panel. Only one format is valid for each locale.

The valid date formats are listed in the following table. Use the format most similar to the format selected for Short date in Regional and Language Options in Control Panel on the local computer.

/SD <STARTDATE>

ValueDescription
<MM>//Use for month-first formats, such as English (United States) and Spanish (Panama).
<DD>//Use for day-first formats, such as Bulgarian and Dutch (Netherlands).
<YYYY>//Use for year-first formats, such as Swedish and French (Canada).

/ed <EndDate>

Specifies the date on which the schedule ends. This parameter is optional. It is not valid in a ONCE, ONSTART, ONLOGON, or ONIDLE schedule. By default, schedules have no ending date.

The format for EndDate varies with the locale selected for the local computer in Regional and Language Options in Control Panel. Only one format is valid for each locale.

The valid date formats are listed in the following table. Use the format most similar to the format selected for Short date in Regional and Language Options in Control Panel on the local computer.

TABLE 6

ValueDescription
<MM>//Use for month-first formats, such as English (United States) and Spanish (Panama).
<DD>//Use for day-first formats, such as Bulgarian and Dutch (Netherlands).
<YYYY>//Use for year-first formats, such as Swedish and French (Canada).
/it

Specifies to run the task only when the run as user (the user account under which the task runs) is logged on to the computer. This parameter has no effect on tasks that run with system permissions.

By default, the run as user is the current user of the local computer when the task is scheduled or the account specified by the /u parameter, if one is used. However, if the command includes the /ru parameter, then the run as user is the account specified by the /ru parameter.

For examples, see:

  • To schedule a task that runs every 70 days if I am logged on in the To schedule a task that runs every N days section.
  • To run a task only when a particular user is logged on in the To schedule a task that runs with different permissions section.
/z

Specifies to delete the task upon completion of its schedule.

/f

Specifies to create the task and suppress warnings if the specified task already exists

...

Command Exemples

Create a scheduled task that runs everyday at 09:00 AM (starts today)

SCHTASKS /CREATE /SC DAILY /TN "The name of my scheduled task" /TR "C:\Users\Admin\Documents\Scripts\ScriptToRun.vbs" /ST 09:00

Delete a task (without a confirmation prompt)

SCHTASKS /DELETE /TN "The name of my scheduled task" /F

Integration within the proVConnect console

1) Use the launch command

On your provconnect manager, open the command list menu, choose a Launch command and type your SCHTASKS command exactly like you would type it in the windows command prompt.

Image Removed

2) Save your task

Click on the Save As button and save your task, so you can reload and use it as many time as you want. You can create a category for your task. On the image below, the category is called scheduled task.

Image Removed

3) Publish your task

You finally need to publish your task on your devices.

Image Removed