add run asap after missed wh1te909/tacticalrmm#247

This commit is contained in:
wh1te909 2021-02-23 21:30:44 -08:00
parent e8f4ea84dc
commit 78c61da189
1 changed files with 21 additions and 16 deletions

View File

@ -110,22 +110,23 @@ func (a *WindowsAgent) CreateInternalTask(name, args, repeat string, start int)
}
type SchedTask struct {
PK int `json:"pk"`
Type string `json:"type"`
Name string `json:"name"`
Trigger string `json:"trigger"`
Enabled bool `json:"enabled"`
DeleteAfter bool `json:"deleteafter"`
WeekDays taskmaster.DayOfWeek `json:"weekdays"`
Year int `json:"year"`
Month string `json:"month"`
Day int `json:"day"`
Hour int `json:"hour"`
Minute int `json:"min"`
Path string `json:"path"`
WorkDir string `json:"workdir"`
Args string `json:"args"`
Parallel bool `json:"parallel"`
PK int `json:"pk"`
Type string `json:"type"`
Name string `json:"name"`
Trigger string `json:"trigger"`
Enabled bool `json:"enabled"`
DeleteAfter bool `json:"deleteafter"`
WeekDays taskmaster.DayOfWeek `json:"weekdays"`
Year int `json:"year"`
Month string `json:"month"`
Day int `json:"day"`
Hour int `json:"hour"`
Minute int `json:"min"`
Path string `json:"path"`
WorkDir string `json:"workdir"`
Args string `json:"args"`
Parallel bool `json:"parallel"`
RunASAPAfterMissed bool `json:"run_asap_after_missed"`
}
func (a *WindowsAgent) CreateSchedTask(st SchedTask) (bool, error) {
@ -221,6 +222,10 @@ func (a *WindowsAgent) CreateSchedTask(st SchedTask) (bool, error) {
def.Settings.MultipleInstances = taskmaster.TASK_INSTANCES_IGNORE_NEW
}
if st.RunASAPAfterMissed {
def.Settings.StartWhenAvailable = true
}
_, success, err := conn.CreateTask(fmt.Sprintf("\\%s", st.Name), def, true)
if err != nil {
a.Logger.Errorln(err)