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 **
That is correct. Creating a LogonTrigger without specifying a UserId value would apply that trigger to all users. It makes sense that an unprivileged account should not be able to create a task that affects other users. Thanks for documenting your solution.