This project has moved. For the latest updates, please go here.

Cannot create task with BootTrigger programmatically

Topics: Errors
Aug 30 at 3:47 PM
Edited Aug 30 at 3:47 PM
I want to create a task with BootTrigger programmatically. The issue is that when I try to create it, I get an access denied exception, even if the user has admin rights. Is there anything that I am doing wrong?
var trigger = new BootTrigger();
trigger.Delay = TimeSpan.FromMinutes(2);
trigger.Repetition = new RepetitionPattern(TimeSpan.FromMinutes(1), TimeSpan.Zero);
var accion = new ExecAction(Path.GetFullPath("executable.exe"));
ts.AddTask("task", trigger, accion, "username", "password", TaskLogonType.Password, "task");