Quantcast
Channel: Task Scheduler Managed Wrapper
Viewing all articles
Browse latest Browse all 2206

New Post: Add task from xml string

$
0
0
NewTaskFromFile will give you a TaskDefinition but does not create (register) the task. The problem you may be having is a permissions problem when registering. Are you running the executable from an account that has permissions to create tasks? Are you not running as Administrator and having UAC block your access? Your code is correct if you have permissions. Alternately, you could do all that in one line:
TaskService.Instance.RootFolder.ImportTask("XMLTask", @"D:\DailyTrigger.xml");
If you have permission problems, you may need to supply user information:
using (var ts = new TaskService())
{
   // If user information is in the XML file under the Principal tag, you can use this short form:
   ts.RootFolder.RegisterTaskDefinition("XMLTask", ts.NewTaskFromFile(@"D:\DailyTrigger.xml"));
   // If you need to supply user information at this time use this form. See documentation for detail on TaskLogonType.
   ts.RootFolder.RegisterTaskDefinition("XMLTask", ts.NewTaskFromFile(@"D:\DailyTrigger.xml"),
      TaskCreation.CreateOrUpdate, "username", "password", TaskLogonType.XYZ);
}

Viewing all articles
Browse latest Browse all 2206

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>