Scheduler.ahk

Summary
Scheduler.ahk
CreateCreates new scheduled task.
ClearVarClears the global array.
DeleteDelete specified scheduled task
QueryQuery specified scheduled task or all tasks.
ExistsCheck if task exists.
ExistsCheck if task exists.
OpenOpens or activates the Task Scheduler.
About

Create

Scheduler_Create(v,  
bForce = false)

Creates new scheduled task.

Parameters

NameSpecifies a name for the task
RunSpecifies the program or command that the task runs.
ArgsArguments of the program that the task runs.
TypeMINUTE, HOURLY, DAILY, WEEKLY, MONTHLY, ONCE, ONSTART, ONLOGON, ONIDLE.  By default, ONCE.
ModModifier, number, Specifies how often the task runs within its schedule type (defaults to 1).  See bellow.
DaySpecifies a day of the week or a day of a month.  Valid only with a WEEKLY or MONTHLY schedule.  For WEEKLY type, valid values are MON-SUN and * (every day).  MON is the default.  A value of MON-SUN is required when the FIRST, SECOND, THIRD, FOURTH, or LAST modifier is used.  A value of 1-31 is optional and is valid only with no modifier or a modifier of the 1-12 type.
MonthSpecifies a month of the year.  Valid values are JAN - DEC and * The 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).
IdleTimeA whole number from 1 to 999.  Specifies how many minutes the computer is idle before the task starts.  This parameter is valid only with an ONIDLE schedule, and then it is required.
TimeSpecifies the time of day that the task starts in HH:MM:SS 24-hour format.  The default value is the current local time when the command completes.  \ Valid with MINUTE, HOURLY, DAILY, WEEKLY, MONTHLY, and ONCE schedules.  It is required with a ONCE schedule.
EndTimeA value that specifies the end time to run the task.  The time format is HH:mm (24-hour time).  For example, 14:50 specifies 2:50PM.  This is not applicable for the following schedule types: ONSTART, ONLOGON, ONIDLE, and ONEVENT.
DurationA value that specifies the duration to run the task.  The time format is HH:mm (24-hour time).  For example, 14:50 specifies 2:50PM.  This is not applicable with /ET and for the following schedule types: ONSTART, ONLOGON, ONIDLE, and ONEVENT.  For /V1 tasks (Task Scheduler 1.0 tasks), if /RI is specified, then the duration default is one hour.
StartDateSpecifies the date that the task starts in MM/DD/YYYY format.  The default value is the current date.  Valid with all schedules, and is required for a ONCE schedule.
EndDateSpecifies the last date that the task is scheduled to run.  This parameter is optional.  It is not valid in a ONCE, ONSTART, ONLOGON, or ONIDLE schedule.  By default, schedules have no ending date.
ComputerSpecifies the name or IP address of a remote computer (with or without backslashes).  The default is the local computer.
UserRuns the command with the permissions of the specified user account.  By default, the command runs with the permissions of the user logged on to the computer running SchTasks.
PasswordSpecifies the password of the user account specified in the User parameter (required with it)
FlagsSee bellow.

Flags

KA value that terminates the task at the end time or duration time.  This is not applicable for the following schedule types: ONSTART, ONLOGON, ONIDLE, and ONEVENT.  Either EndTime or Duration must be specified.
ZA value that marks the task to be deleted after its final run.

Modifiers

MINUTE(1 - 1439) The task runs every n minutes.
HOURLY(1 - 23) The task runs every n hours.
DAILY(1 - 365) The task runs every n days.
WEEKLY(1 - 52) The task runs every n weeks.
MONTHLY(1 - 12) The task runs every n months.  LASTDAY - The task runs on the last day of the month.  FIRST, SECOND, THIRD, FOURTH, LAST Use with the /d day parameter to run a task on a particular week and day.  For example, on the third Wednesday of the month.

ClearVar

Scheduler_ClearVar(v)

Clears the global array.

Delete

Scheduler_Delete(Name,  
bForce = false,
User = "",
Password = "",
Computer = "")

Delete specified scheduled task

Parameters

NameSpecifies the name of task to be deleted.  Use “*” to delete all tasks.
bForceSurpess confimration message, false by default.

Query

Scheduler_Query(Name = "",
var = "")

Query specified scheduled task or all tasks.

Parameters

NameSpecifies the name of task.  Use empty string to return all tasks.
varIf non empty, variable prefix for task parameters extraction.

Exists

Scheduler_Exists(Name)

Check if task exists.

Parameter

NameName of the task.

Exists

Check if task exists.

Parameter

NameName of the task.

Open

Scheduler_Open()

Opens or activates the Task Scheduler.

Returns

PID of Task Scheduler process.

Scheduler_Create(v,  
bForce = false)
Creates new scheduled task.
Scheduler_ClearVar(v)
Clears the global array.
Scheduler_Delete(Name,  
bForce = false,
User = "",
Password = "",
Computer = "")
Delete specified scheduled task
Scheduler_Query(Name = "",
var = "")
Query specified scheduled task or all tasks.
Scheduler_Exists(Name)
Check if task exists.
Scheduler_Open()
Opens or activates the Task Scheduler.
Close