Documentation
¶
Index ¶
- type ActionType
- type Actions
- type BootTrigger
- type CalendarTrigger
- type ComHandlerAction
- type DailySchedule
- type Data
- type DaysOfMonth
- type DaysOfWeek
- type EventTrigger
- type ExecAction
- type IdleSettings
- type IdleTrigger
- type LogonTrigger
- type LogonType
- type MonthlyDOWSchedule
- type MonthlySchedule
- type Months
- type MultipleInstancesPolicy
- type NamedValue
- type NamedValuePair
- type NamedValues
- type NetworkSettings
- type Principal
- type Principals
- type RegistrationInfo
- type RegistrationTrigger
- type Repetition
- type RestartOnFailure
- type RunLevelType
- type SendEmailAction
- type SessionStateChangeTrigger
- type Settings
- type ShowMessageAction
- type Task
- type TimeTrigger
- type Triggers
- type WeeklySchedule
- type Weeks
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ActionType ¶
ActionType is the base for all actions (only carries the optional id attribute).
type Actions ¶
type Actions struct {
XMLName xml.Name `xml:"Actions"`
// Context="" lets you override the default ("Author").
Context string `xml:"Context,attr,omitempty"`
Exec []ExecAction `xml:"Exec,omitempty"`
ComHandler []ComHandlerAction `xml:"ComHandler,omitempty"`
SendEmail []SendEmailAction `xml:"SendEmail,omitempty"`
ShowMessage []ShowMessageAction `xml:"ShowMessage,omitempty"`
}
Actions corresponds to <Actions> (actionsType). It may contain any number of each action type, in any order, and carries an optional Context attribute.
type BootTrigger ¶
type BootTrigger struct {
XMLName xml.Name `xml:"BootTrigger"`
Id string `xml:"id,attr,omitempty"`
StartBoundary string `xml:"StartBoundary"`
EndBoundary string `xml:"EndBoundary,omitempty"`
Enabled bool `xml:"Enabled,omitempty"`
Repetition *Repetition `xml:"Repetition,omitempty"`
ExecutionTimeLimit string `xml:"ExecutionTimeLimit,omitempty"`
Delay string `xml:"Delay,omitempty"` // duration after boot
}
BootTrigger starts a task when the system boots. Inherits StartBoundary, EndBoundary, Enabled, Repetition, ExecutionTimeLimit.
type CalendarTrigger ¶
type CalendarTrigger struct {
XMLName xml.Name `xml:"CalendarTrigger"`
Id string `xml:"id,attr,omitempty"`
StartBoundary string `xml:"StartBoundary"`
EndBoundary string `xml:"EndBoundary,omitempty"`
Enabled bool `xml:"Enabled,omitempty"`
Repetition *Repetition `xml:"Repetition,omitempty"`
ExecutionTimeLimit string `xml:"ExecutionTimeLimit,omitempty"`
RandomDelay string `xml:"RandomDelay,omitempty"`
ScheduleByDay *DailySchedule `xml:"ScheduleByDay,omitempty"`
ScheduleByWeek *WeeklySchedule `xml:"ScheduleByWeek,omitempty"`
ScheduleByMonth *MonthlySchedule `xml:"ScheduleByMonth,omitempty"`
ScheduleByMonthDayOfWeek *MonthlyDOWSchedule `xml:"ScheduleByMonthDayOfWeek,omitempty"`
}
CalendarTrigger covers daily, weekly, monthly & DOW schedules.
type ComHandlerAction ¶
type ComHandlerAction struct {
XMLName xml.Name `xml:"ComHandler"`
ActionType
// <ClassId> is the COM class ID (GUID).
ClassId string `xml:"ClassId"`
// <Data> is passed into the handler (optional).
Data string `xml:"Data,omitempty"`
}
ComHandlerAction corresponds to <ComHandler> (comHandlerActionType).
type DailySchedule ¶
type DailySchedule struct {
DaysInterval int `xml:"DaysInterval,omitempty"`
}
DailySchedule (dailyScheduleType): interval in days.
type Data ¶
Data corresponds to the <Data> element under a TaskDefinition. It can contain any well‑formed XML inside.
type DaysOfMonth ¶
type DaysOfMonth struct {
Day []int `xml:"Day,omitempty"`
}
DaysOfMonth (daysOfMonthType): list of numeric days in a month.
type DaysOfWeek ¶
type DaysOfWeek struct {
Monday *struct{} `xml:"Monday,omitempty"`
Tuesday *struct{} `xml:"Tuesday,omitempty"`
Wednesday *struct{} `xml:"Wednesday,omitempty"`
Thursday *struct{} `xml:"Thursday,omitempty"`
Friday *struct{} `xml:"Friday,omitempty"`
Saturday *struct{} `xml:"Saturday,omitempty"`
Sunday *struct{} `xml:"Sunday,omitempty"`
}
DaysOfWeek (daysOfWeekType): a set of empty elements indicating which weekdays.
type EventTrigger ¶
type EventTrigger struct {
XMLName xml.Name `xml:"EventTrigger"`
Id string `xml:"id,attr,omitempty"`
StartBoundary string `xml:"StartBoundary,omitempty"`
EndBoundary string `xml:"EndBoundary,omitempty"`
Enabled bool `xml:"Enabled,omitempty"`
Repetition *Repetition `xml:"Repetition,omitempty"`
ExecutionTimeLimit string `xml:"ExecutionTimeLimit,omitempty"`
Subscription string `xml:"Subscription"` // XPath query
Delay string `xml:"Delay,omitempty"`
ValueQueries *NamedValues `xml:"ValueQueries,omitempty"`
}
EventTrigger fires on matching Windows events.
type ExecAction ¶
type ExecAction struct {
XMLName xml.Name `xml:"Exec"`
ActionType
// <Command> is the program or script to run.
Command string `xml:"Command"`
// <Arguments> are passed to the Command.
Arguments string `xml:"Arguments,omitempty"`
// <WorkingDirectory> sets the cwd for the process.
WorkingDirectory string `xml:"WorkingDirectory,omitempty"`
}
ExecAction corresponds to <Exec> (execActionType).
type IdleSettings ¶
type IdleSettings struct {
XMLName xml.Name `xml:"IdleSettings"`
StopOnIdleEnd bool `xml:"StopOnIdleEnd,omitempty"`
RestartOnIdle bool `xml:"RestartOnIdle,omitempty"`
Duration string `xml:"Duration,omitempty"` // xs:duration (deprecated)
WaitTimeout string `xml:"WaitTimeout,omitempty"` // xs:duration (deprecated)
}
IdleSettings corresponds to <IdleSettings> (idleSettingsType), controlling idle‐based execution.
type IdleTrigger ¶
type IdleTrigger struct {
XMLName xml.Name `xml:"IdleTrigger"`
Id string `xml:"id,attr,omitempty"`
StartBoundary string `xml:"StartBoundary"`
EndBoundary string `xml:"EndBoundary,omitempty"`
Enabled bool `xml:"Enabled,omitempty"`
Repetition *Repetition `xml:"Repetition,omitempty"`
ExecutionTimeLimit string `xml:"ExecutionTimeLimit,omitempty"`
}
IdleTrigger fires when the system goes idle.
type LogonTrigger ¶
type LogonTrigger struct {
XMLName xml.Name `xml:"LogonTrigger"`
Id string `xml:"id,attr,omitempty"`
StartBoundary string `xml:"StartBoundary"`
EndBoundary string `xml:"EndBoundary,omitempty"`
Enabled bool `xml:"Enabled,omitempty"`
Repetition *Repetition `xml:"Repetition,omitempty"`
ExecutionTimeLimit string `xml:"ExecutionTimeLimit,omitempty"`
UserId string `xml:"UserId,omitempty"`
Delay string `xml:"Delay,omitempty"`
}
LogonTrigger fires on user logon (optionally scoped by UserId).
type MonthlyDOWSchedule ¶
type MonthlyDOWSchedule struct {
Weeks *Weeks `xml:"Weeks,omitempty"`
DaysOfWeek DaysOfWeek `xml:"DaysOfWeek"`
Months *Months `xml:"Months,omitempty"`
}
MonthlyDOWSchedule (monthlyDayOfWeekScheduleType): weeks of month + days + months.
type MonthlySchedule ¶
type MonthlySchedule struct {
DaysOfMonth *DaysOfMonth `xml:"DaysOfMonth,omitempty"`
Months *Months `xml:"Months,omitempty"`
}
MonthlySchedule (monthlyScheduleType): specific month days + months.
type Months ¶
type Months struct {
January *struct{} `xml:"January,omitempty"`
February *struct{} `xml:"February,omitempty"`
March *struct{} `xml:"March,omitempty"`
April *struct{} `xml:"April,omitempty"`
May *struct{} `xml:"May,omitempty"`
June *struct{} `xml:"June,omitempty"`
July *struct{} `xml:"July,omitempty"`
August *struct{} `xml:"August,omitempty"`
September *struct{} `xml:"September,omitempty"`
October *struct{} `xml:"October,omitempty"`
November *struct{} `xml:"November,omitempty"`
December *struct{} `xml:"December,omitempty"`
}
Months (monthsType): empty elements for each month.
type MultipleInstancesPolicy ¶
type MultipleInstancesPolicy string
MultipleInstancesPolicy enumerates policies for concurrent task instances.
const ( Parallel MultipleInstancesPolicy = "Parallel" Queue MultipleInstancesPolicy = "Queue" IgnoreNew MultipleInstancesPolicy = "IgnoreNew" StopExisting MultipleInstancesPolicy = "StopExisting" )
type NamedValue ¶
type NamedValue struct {
XMLName xml.Name `xml:"Value"`
Name string `xml:"name,attr"`
Value string `xml:",chardata"`
}
NamedValue is one name/value pair.
type NamedValuePair ¶
type NamedValuePair struct {
XMLName xml.Name `xml:"Identification"`
Name string `xml:"name,attr"`
Value string `xml:"value,attr"`
}
NamedValuePair represents one <Identification name="…" value="…"/> entry within RegistrationInfo.
type NamedValues ¶
type NamedValues struct {
XMLName xml.Name `xml:"HeaderFields"`
Value []NamedValue `xml:"Value"`
}
NamedValues holds zero or more <Value name="…">…</Value> entries.
type NetworkSettings ¶
type NetworkSettings struct {
XMLName xml.Name `xml:"NetworkSettings"`
Name string `xml:"Name,omitempty"` // nonEmptyString
Id string `xml:"Id,omitempty"` // guidType
}
NetworkSettings corresponds to <NetworkSettings> (networkSettingsType), specifying which network profile to await.
type Principal ¶
type Principal struct {
XMLName xml.Name `xml:"Principal"`
Id string `xml:"id,attr,omitempty"`
UserId string `xml:"UserId,omitempty"` // xs:string
GroupId string `xml:"GroupId,omitempty"` // xs:string
RunLevel RunLevelType `xml:"RunLevel,omitempty"` // default="LeastPrivilege"
LogonType LogonType `xml:"LogonType,omitempty"` // default="InteractiveToken"
DisplayName string `xml:"DisplayName,omitempty"` // xs:string
}
Principal corresponds to the <Principal> element within <Principals>.
type Principals ¶
type Principals struct {
XMLName xml.Name `xml:"Principals"`
Principal []Principal `xml:"Principal"`
}
Principals corresponds to the <Principals> element. It holds one or more <Principal> entries.
type RegistrationInfo ¶
type RegistrationInfo struct {
XMLName xml.Name `xml:"RegistrationInfo"`
Date string `xml:"Date,omitempty"` // xs:dateTime
Author string `xml:"Author,omitempty"` // xs:string
Description string `xml:"Description,omitempty"` // xs:string
URI string `xml:"URI,omitempty"` // xs:string
Version string `xml:"Version,omitempty"` // xs:string
Source string `xml:"Source,omitempty"` // xs:string
Documentation string `xml:"Documentation,omitempty"` // xs:string
SecurityDescriptor string `xml:"SecurityDescriptor,omitempty"` // xs:string (SDDL)
Identification []NamedValuePair `xml:"Identification,omitempty"` // zero or more
}
RegistrationInfo corresponds to the <RegistrationInfo> element.
Fields are all optional and appear in the same order as in the XSD.
type RegistrationTrigger ¶
type RegistrationTrigger struct {
XMLName xml.Name `xml:"RegistrationTrigger"`
Id string `xml:"id,attr,omitempty"`
StartBoundary string `xml:"StartBoundary"`
EndBoundary string `xml:"EndBoundary,omitempty"`
Enabled bool `xml:"Enabled,omitempty"`
Repetition *Repetition `xml:"Repetition,omitempty"`
ExecutionTimeLimit string `xml:"ExecutionTimeLimit,omitempty"`
Delay string `xml:"Delay,omitempty"`
}
RegistrationTrigger fires when the task is registered or updated.
type Repetition ¶
type Repetition struct {
XMLName xml.Name `xml:"Repetition"`
Interval string `xml:"Interval"` // duration, e.g. PT5M
StopAtDurationEnd bool `xml:"StopAtDurationEnd,omitempty"` // default=false
Duration string `xml:"Duration,omitempty"` // duration, max span
}
Repetition corresponds to the <Repetition> element (repetitionType), defining how often and for how long a trigger will re‑fire.
type RestartOnFailure ¶
type RestartOnFailure struct {
XMLName xml.Name `xml:"RestartOnFailure"`
Interval string `xml:"Interval"` // xs:duration (min PT1M, max P31D)
Count uint8 `xml:"Count"` // unsignedByte ≥1
}
RestartOnFailure corresponds to <RestartOnFailure> (restartType), retrying a failed task.
type RunLevelType ¶
type RunLevelType string
RunLevelType enumerates the RunLevel element values.
const ( RunLevelLeastPrivilege RunLevelType = "LeastPrivilege" RunLevelHighestAvailable RunLevelType = "HighestAvailable" )
type SendEmailAction ¶
type SendEmailAction struct {
XMLName xml.Name `xml:"SendEmail"`
ActionType
Server string `xml:"Server"` // SMTP server
Subject string `xml:"Subject"` // email subject
To string `xml:"To"` // semicolon‑separated
Cc string `xml:"Cc,omitempty"`
Bcc string `xml:"Bcc,omitempty"`
ReplyTo string `xml:"ReplyTo,omitempty"`
Body string `xml:"Body,omitempty"`
// optional named header fields
HeaderFields *NamedValues `xml:"HeaderFields,omitempty"`
}
SendEmailAction corresponds to <SendEmail> (sendEmailActionType).
type SessionStateChangeTrigger ¶
type SessionStateChangeTrigger struct {
XMLName xml.Name `xml:"SessionStateChangeTrigger"`
Id string `xml:"id,attr,omitempty"`
StartBoundary string `xml:"StartBoundary,omitempty"`
EndBoundary string `xml:"EndBoundary,omitempty"`
Enabled bool `xml:"Enabled,omitempty"`
Repetition *Repetition `xml:"Repetition,omitempty"`
ExecutionTimeLimit string `xml:"ExecutionTimeLimit,omitempty"`
StateChange string `xml:"StateChange"` // e.g. “Connect” or “Disconnect”
UserId string `xml:"UserId,omitempty"`
Delay string `xml:"Delay,omitempty"`
}
SessionStateChangeTrigger fires on terminal‑server session changes.
type Settings ¶
type Settings struct {
XMLName xml.Name `xml:"Settings"`
AllowStartOnDemand bool `xml:"AllowStartOnDemand,omitempty"`
RestartOnFailure *RestartOnFailure `xml:"RestartOnFailure,omitempty"`
MultipleInstancesPolicy MultipleInstancesPolicy `xml:"MultipleInstancesPolicy,omitempty"`
DisallowStartIfOnBatteries bool `xml:"DisallowStartIfOnBatteries,omitempty"`
StopIfGoingOnBatteries bool `xml:"StopIfGoingOnBatteries,omitempty"`
AllowHardTerminate bool `xml:"AllowHardTerminate,omitempty"`
StartWhenAvailable bool `xml:"StartWhenAvailable,omitempty"`
NetworkProfileName string `xml:"NetworkProfileName,omitempty"`
RunOnlyIfNetworkAvailable bool `xml:"RunOnlyIfNetworkAvailable,omitempty"`
WakeToRun bool `xml:"WakeToRun,omitempty"`
Enabled bool `xml:"Enabled,omitempty"`
Hidden bool `xml:"Hidden,omitempty"`
DeleteExpiredTaskAfter string `xml:"DeleteExpiredTaskAfter,omitempty"`
IdleSettings *IdleSettings `xml:"IdleSettings,omitempty"`
NetworkSettings *NetworkSettings `xml:"NetworkSettings,omitempty"`
ExecutionTimeLimit string `xml:"ExecutionTimeLimit,omitempty"`
Priority byte `xml:"Priority,omitempty"`
RunOnlyIfIdle bool `xml:"RunOnlyIfIdle,omitempty"`
UseUnifiedSchedulingEngine bool `xml:"UseUnifiedSchedulingEngine,omitempty"`
DisallowStartOnRemoteAppSession bool `xml:"DisallowStartOnRemoteAppSession,omitempty"`
}
Settings mirrors the <Settings> element (settingsType).
type ShowMessageAction ¶
type ShowMessageAction struct {
XMLName xml.Name `xml:"ShowMessage"`
ActionType
Title string `xml:"Title"` // window title
Message string `xml:"Message"` // body text
}
ShowMessageAction corresponds to <ShowMessage> (showMessageActionType).
type Task ¶
type Task struct {
XMLName xml.Name `xml:"Task"`
Version string `xml:"version,attr"` // required
Xmlns string `xml:"xmlns,attr,omitempty"` // e.g. "http://schemas.microsoft.com/windows/2004/02/mit/task"
RegistrationInfo *RegistrationInfo `xml:"RegistrationInfo,omitempty"`
Triggers *Triggers `xml:"Triggers,omitempty"`
Principals *Principals `xml:"Principals,omitempty"`
Settings *Settings `xml:"Settings,omitempty"`
Actions *Actions `xml:"Actions"` // required
Data *Data `xml:"Data,omitempty"`
}
Task represents the root <Task> element (type TaskDefinitionType). It pulls together RegistrationInfo, Triggers, Principals, Settings, Actions, and Data.
type TimeTrigger ¶
type TimeTrigger struct {
XMLName xml.Name `xml:"TimeTrigger"`
Id string `xml:"id,attr,omitempty"`
StartBoundary string `xml:"StartBoundary"`
EndBoundary string `xml:"EndBoundary,omitempty"`
Enabled bool `xml:"Enabled,omitempty"`
Repetition *Repetition `xml:"Repetition,omitempty"`
ExecutionTimeLimit string `xml:"ExecutionTimeLimit,omitempty"`
RandomDelay string `xml:"RandomDelay,omitempty"` // optional jitter
}
TimeTrigger fires once at a given time. Adds RandomDelay to the base trigger.
type Triggers ¶
type Triggers struct {
XMLName xml.Name `xml:"Triggers"`
Boot []BootTrigger `xml:"BootTrigger,omitempty"`
Time []TimeTrigger `xml:"TimeTrigger,omitempty"`
Calendar []CalendarTrigger `xml:"CalendarTrigger,omitempty"`
Event []EventTrigger `xml:"EventTrigger,omitempty"`
Idle []IdleTrigger `xml:"IdleTrigger,omitempty"`
Logon []LogonTrigger `xml:"LogonTrigger,omitempty"`
Registration []RegistrationTrigger `xml:"RegistrationTrigger,omitempty"`
SessionStateChange []SessionStateChangeTrigger `xml:"SessionStateChangeTrigger,omitempty"`
}
Triggers corresponds to the <Triggers> container (triggersType) and may hold any number of each trigger type, in schema order.
type WeeklySchedule ¶
type WeeklySchedule struct {
WeeksInterval int `xml:"WeeksInterval,omitempty"`
DaysOfWeek *DaysOfWeek `xml:"DaysOfWeek,omitempty"`
}
WeeklySchedule (weeklyScheduleType): weeks interval + days flag.