Skip to content

Problem setting RepetitionInterval #15

Description

@wh1te909

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
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions