-
Notifications
You must be signed in to change notification settings - Fork 34
Open
Description
Hi, I'm trying to create a scheduled task that runs daily and repeats every hour indefinitely, the below code works only when I comment out the line
RepetitionInterval: period.NewHMS(1, 0, 0),
otherwise it throws this error:
error creating registered task \TacticalRMM_fixmesh: error registering task: The task XML contains a value which is incorrectly formatted or out of range.
Am I doing something wrong or this is bug?
Thanks!
func CreateSchedTask() bool {
conn, err := taskmaster.Connect()
if err != nil {
panic(err)
}
defer conn.Disconnect()
def := conn.NewTaskDefinition()
dailyTrigger := taskmaster.DailyTrigger{
TaskTrigger: taskmaster.TaskTrigger{
Enabled: true,
StartBoundary: time.Now().Add(5 * time.Minute),
RepetitionPattern: taskmaster.RepetitionPattern{
RepetitionDuration: period.NewYMD(100, 0, 0),
RepetitionInterval: period.NewHMS(1, 0, 0), // this is the problem line
StopAtDurationEnd: false,
},
},
DayInterval: taskmaster.EveryDay,
}
def.AddTrigger(dailyTrigger)
action := taskmaster.ExecAction{
Path: "tacticalrmm.exe",
WorkingDir: `C:\Program Files\TacticalAgent`,
Args: "-m fixmesh",
}
def.AddAction(action)
def.Principal.RunLevel = taskmaster.TASK_RUNLEVEL_HIGHEST
def.Principal.LogonType = taskmaster.TASK_LOGON_SERVICE_ACCOUNT
def.Principal.UserID = "SYSTEM"
def.Settings.AllowDemandStart = true
def.Settings.AllowHardTerminate = true
def.Settings.DontStartOnBatteries = false
def.Settings.Enabled = true
def.Settings.MultipleInstances = taskmaster.TASK_INSTANCES_IGNORE_NEW
def.Settings.StopIfGoingOnBatteries = false
def.Settings.WakeToRun = true
_, success, err := conn.CreateTask("\\TacticalRMM_fixmesh", def, true)
if err != nil {
panic(err)
}
return success
}
Metadata
Metadata
Assignees
Labels
No labels