title: Edit scheduled task programmatically
body: <p>I need to be able to edit some settings without user interaction, for example this one:<br>
  <img src="https://i.imgur.com/F0spaux.png" alt="Screenshot"></p>
  
  <p>I already am creating it like that:</p>
  
  <pre><code>using Microsoft.Win32.TaskScheduler;
  
  /* ... */
  
  try
  {
      ScheduledTasks.RootFolder.DeleteTask("Task");
  }
  catch (Exception) { }
  TaskDefinition TaskProperties = ScheduledTasks.NewTask();
  TaskProperties.RegistrationInfo.Description = "Runs background stuff";
  TaskProperties.Actions.Add(new ExecAction(Process.GetCurrentProcess().MainModule.FileName, "/background", null));
  ScheduledTasks.RootFolder.RegisterTaskDefinition(@"Task", TaskProperties);
  </code></pre>
  
  <p><code>schtasks.exe</code> doesn't give a way to edit it, neither does <a href="https://taskscheduler.codeplex.com/" rel="nofollow noreferrer">Task Scheduler Managed Wrapper</a>, but the Task Scheduler GUI does, and there is also a <a href="https://msdn.microsoft.com/en-us/library/windows/desktop/aa381848.aspx" rel="nofollow noreferrer">C++ API</a>. How can I edit these settings? I don't really mind if the solution involves <code>PInvoke</code>. Bonus &lt;3 for code snippet.</p>
  
  <p>Note: I do not want a separated XML file to import, since the .exe is supposed to be standalone, and some elements may vary between systems (For example, the location of the file)</p>