Hello,
I'm creating a simple planned task like this:
```
using (TaskService ts = new TaskService())
{
TaskDefinition td = ts.NewTask();
td.RegistrationInfo.Description = "AutoRestartTest";
LogonTrigger mainTrigger = new LogonTrigger();
mainTrigger.ExecutionTimeLimit = TimeSpan.FromDays(30);
mainTrigger.Repetition.Interval = TimeSpan.FromMinutes(1);
td.Triggers.Add(mainTrigger);
td.Actions.Add(new ExecAction(@"C:\example.exe", null, null));
ts.RootFolder.RegisterTaskDefinition(@"TestTask1", td);
}
```
And I am getting this exception at the last line of the code:
Access Denied (Exception of HRESULT: 0x80070005 (E_ACCESSDENIED))
I have created a Manifest-File to take care of this option being set to this:
```
<requestedExecutionLevel level="highestAvailable" uiAccess="false" />
```
Please help!
What am I doing wrong?
Greetings,
Tom
ps. I dont know why code inserted in the codeblock remains black/white.
Comments: ** Comment from web user: dahall **
I'm creating a simple planned task like this:
```
using (TaskService ts = new TaskService())
{
TaskDefinition td = ts.NewTask();
td.RegistrationInfo.Description = "AutoRestartTest";
LogonTrigger mainTrigger = new LogonTrigger();
mainTrigger.ExecutionTimeLimit = TimeSpan.FromDays(30);
mainTrigger.Repetition.Interval = TimeSpan.FromMinutes(1);
td.Triggers.Add(mainTrigger);
td.Actions.Add(new ExecAction(@"C:\example.exe", null, null));
ts.RootFolder.RegisterTaskDefinition(@"TestTask1", td);
}
```
And I am getting this exception at the last line of the code:
Access Denied (Exception of HRESULT: 0x80070005 (E_ACCESSDENIED))
I have created a Manifest-File to take care of this option being set to this:
```
<requestedExecutionLevel level="highestAvailable" uiAccess="false" />
```
Please help!
What am I doing wrong?
Greetings,
Tom
ps. I dont know why code inserted in the codeblock remains black/white.
Comments: ** Comment from web user: dahall **
Please look over the information at https://taskscheduler.codeplex.com/wikipage?title=TaskSecurity. My guess is that the LogonTrigger with no user specified requires higher permissions than the running process has. Please let me know if that page answers your question. Also check the Microsoft pages for more information on registering tasks. The error you're seeing is from the native Microsoft library and not this wrapper.