Unable to add a task - AccessDenied
See original GitHub issueIn Windows any unprivileged user can create a task for yourself in Interactive Token mode (“run only when user is logged on”). Looks like I can’t do that via TaskService. I’ve tried 2 ways:
TaskService.Instance.AddTask("app_"+sid, QuickTriggerType.Logon, path, "-agent");
and
using (var ts = new TaskService())
{
var td = ts.NewTask();
td.Actions.Add(path, "-agent");
var tr = td.Triggers.AddNew(TaskTriggerType.Logon);
td.Principal.LogonType = TaskLogonType.InteractiveToken;
ts.RootFolder.RegisterTaskDefinition("app_" + sid, td);
}
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:21 (9 by maintainers)
Top Results From Across the Web
Task Manager gives me an access denied error when I try ...
1. Open Task Manager. Go to the Process Tab. 2. Right-click on the GoogleToolbarNotifier Process and click on Properties. 3. Click on ...
Read more >"Access Denied" or other errors when you access or work ...
Issue 1: I receive an "Access Denied" error message when I try to access or work with files and folders · Press and...
Read more >windows - unable to schedule a task (access denied)
Proceed with scheduling task or whatever you were doing before getting the dreaded "Access Denied" Error. Hope this helps!
Read more >c# - .NET create scheduled task on server fails with ...
I've done some searching, and the suggested resolution is to use the web.config 'impersonate' flag to force the application to run as a...
Read more >Solved: cannot create scheduled task, access denied
The new task could not be created. The specific error is: 0x80070005: Access is denied. Try using the Task page Browse button to...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
After doing a little more research and testing, I found that in order to use the LogonTrigger as a non-privileged user you must specify the current user’s account (DOMAIN\username) in the UserId property and register the task as either interactive (default) or with the user account and password.
The following will work.
Given this, I will be updating this library to automatically set that property in this condition.
@longhibianca See this help link. Use
null
or""
for a local computer.