使用Task Scheduler Managed Wrapper库在C#中以编程方式创建任务时出错

时间:2018-10-04 16:46:10

标签: asp.net asp.net-mvc-4

我正在使用nuget库,以创建我在以下代码段中使用的任务。

TaskService.Instance.AddTask("Test", QuickTriggerType.Daily, "myprogram.exe", "-a arg");

还尝试了以下代码段

using (TaskService ts = new TaskService())
      {
         // Create a new task definition and assign properties
         TaskDefinition td = ts.NewTask();
         td.RegistrationInfo.Description = "Does something";

         // Create a trigger that will fire the task at this time every other day
         td.Triggers.Add(new DailyTrigger { DaysInterval = 2 });

         // Create an action that will launch Notepad whenever the trigger fires
         td.Actions.Add(new ExecAction("notepad.exe", "c:\\test.log", null));

         // Register the task in the root folder
         ts.RootFolder.RegisterTaskDefinition(@"Test", td);

         // Remove the task we just created
         ts.RootFolder.DeleteTask("Test");
      }

我在两者上都遇到相同的错误

  

System.Runtime.InteropServices.COMException:'(42,4):Task:'

这里是所使用软件包的链接 https://github.com/dahall/taskscheduler

0 个答案:

没有答案