使用C#在任务计划程序中进行常规设置
作者:互联网
我想将任务计划程序中的“配置为”设置为“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");
}
任何帮助,将不胜感激 !!
解决方法:
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,
}
标签:c,taskscheduler 来源: https://codeday.me/bug/20190623/1268399.html