I'm creating a scheduled task using c# from a MVC app. It works fine, but I am not able to add a BootTrigger:
TaskDefinition td = ts.NewTask();
TaskService ts = new TaskService();
td.RegistrationInfo.Description = "Some Description";
...
td.Triggers.Add(new BootTrigger()); //Leaving this line out, does not give the error.
...
ts.RootFolder.RegisterTaskDefinition("My Task", td);
The code gives the error:
Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
Based on other posts I need to run the app As Administrator or add a manifest file with relevant settings, but as this is a MVC site running in IIS these options are not available.
How else can I add a Boot Trigger to a Scheduled Task? Or trigger the task to run at system startup?