Reputation: 4158
I would like to set the "Configure for" setting in Task Scheduler to "Windows 7".
Current C# code:
using (TaskService ts = new TaskService())
{
TaskDefinition td = ts.NewTask();
TimeTrigger trigger = new TimeTrigger();
var startTime = TimeSpan.Parse(section1["ScheduledTime"]);
trigger.StartBoundary = DateTime.Today + startTime;
trigger.Repetition.Interval = TimeSpan.FromDays(1);
td.Triggers.Add(trigger);
td.Actions.Add(new ExecAction(@"Data.exe", argument, null));
var foldername = ts.GetFolder(@"\Bigdata");
Console.WriteLine(foldername.Path);
foldername.RegisterTaskDefinition(section1["JobName"], td, TaskCreation.CreateOrUpdate, "[email protected]", "traincloudCubel!ne");
}
Any help would be appreciated !!
Upvotes: 5
Views: 2193
Reputation: 127563
td.Settings.Compatibility
should map to that field.
See the xmldoc on the enum for what each version maps to in the dropdown.
/// <summary>Defines what versions of Task Scheduler or the AT command that the task is compatible with.</summary>
public enum TaskCompatibility
{
/// <summary>The task is compatible with the AT command.</summary>
AT,
/// <summary>The task is compatible with Task Scheduler 1.0 (Windows Server™ 2003, Windows® XP, or Windows® 2000).</summary>
V1,
/// <summary>The task is compatible with Task Scheduler 2.0 (Windows Vista™, Windows Server™ 2008).</summary>
V2,
/// <summary>The task is compatible with Task Scheduler 2.1 (Windows® 7, Windows Server™ 2008 R2).</summary>
V2_1,
/// <summary>The task is compatible with Task Scheduler 2.2 (Windows® 8.x, Windows Server™ 2012).</summary>
V2_2,
/// <summary>The task is compatible with Task Scheduler 2.3 (Windows® 10, Windows Server™ 2016).</summary>
V2_3,
}
Upvotes: 6