4

我想将任务计划程序中的“配置”设置为“Windows 7”。

当前的 C# 代码:

 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, "service@geotab.local", "traincloudCubel!ne");
  }

任何帮助,将不胜感激 !!

在此处输入图像描述

4

1 回答 1

6

td.Settings.Compatibility应该映射到该字段。

请参阅枚举上的 xmldoc,了解每个版本在下拉列表中映射到的内容。

/// <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,
}
于 2016-07-07T03:12:41.270 回答