I'm using the TaskService class to create and edit Windows Scheduled Tasks. One problem I have is how to save a new trigger on an existing Scheduled Task. The trigger does not seem to save.
var task = new TaskService().FindTask("My Scheduled Task");
BootTrigger trigger = new BootTrigger();
var td = task.Definition;
//td.Triggers.Count = 1 at this point
td.Triggers.Add(trigger);
//td.Triggers.Count = 2 at this point
So the code seems okay. But if I open the Scheduled Task in Windows, only 1 trigger is shown and not the one I added. If I run my code again, the trigger count is back to 1, so it seems like there should be some Commit() or Save() function. What am I missing?