title: update task using Task Scheduler Managed Wrapper?
body: <p>Here's the library I'm using:
  <a href="http://taskscheduler.codeplex.com/wikipage?title=Install&amp;referringTitle=Documentation" rel="nofollow">http://taskscheduler.codeplex.com/wikipage?title=Install&amp;referringTitle=Documentation</a></p>
  
  <p>Here's the code</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  
  using Microsoft.Win32.TaskScheduler;
  
  namespace ConsoleApplication1 {
    class Program {
      static void Main(string[] args) {
        var p = new Program();
        p.EnumAllTasks();
  
      }
      void EnumAllTasks() {
        using (TaskService ts = new TaskService())
          EnumFolderTasks(ts,ts.RootFolder);
      }
  
      void EnumFolderTasks(TaskService ts, TaskFolder fld) {
        var tasks = fld.Tasks.Where(t =&gt; t.Name.Equals("test-task", StringComparison.OrdinalIgnoreCase));
  
        foreach (Task task in tasks)
          ActOnTask(ts, task);
      }
  
      void ActOnTask(TaskService ts, Task t) {
        //ea.Path
        Console.WriteLine(t.Name);
        Console.WriteLine(t.Path);
        Console.WriteLine(((ExecAction)t.Definition.Actions.First()).Path);
        var ea = (ExecAction)t.Definition.Actions.First();
  
        ea.Path = ea.Path + ".coolio/test.exe";
        UpdateFirstAction(t, new ExecAction(ea.Path+".coolio/test.exe",ea.Arguments,ea.WorkingDirectory));
        //ts.s
        // Do something interesting here
      }
  
      void UpdateFirstAction(Task t, Microsoft.Win32.TaskScheduler.Action action) {
        if (t.TaskService.HighestSupportedVersion &gt;= new Version(1, 2)) {
          Console.WriteLine("HERE");
          t.Definition.Actions.RemoveAt(0);
        }
        t.Definition.Actions.Add(action);
      }
  
    }
  }
  </code></pre>
  
  <p>I added the 'UpdateFirstAction' method based upon the following: <a href="https://taskscheduler.codeplex.com/discussions/203704" rel="nofollow">https://taskscheduler.codeplex.com/discussions/203704</a></p>
  
  <p>I want to be able to update the path that's getting executed, and the above link seems to imply that updating the collection is enough.</p>
  
  <p>How do I actually <em>save</em> the changes?  All of the documentation I've read seems to describe how to read things only.</p>