This project has moved and is read-only. For the latest updates, please go here.

How to run task under the SYSTEM account without E_ACCESSDENIED?

Apr 17, 2012 at 11:06 AM
Edited Apr 17, 2012 at 11:22 AM

I want to run a task even if the user is logged off but don't want to request the password of the currently logged on user, hence wanting to schedule as the SYSTEM account.

This is the code:

ts.RootFolder.RegisterTaskDefinition(@"My Task Name", td, TaskCreation.CreateOrUpdate, "SYSTEM", null, TaskLogonType.ServiceAccount, null);

However when run, I get an E_ACCESSDENIED exception.

Apr 17, 2012 at 3:02 PM

Where do you get the exception? At which method call?

Apr 18, 2012 at 9:26 AM

The exception is thrown by the RegisterTaskDefinition method.

I notice if I run the application as an administrator it works fine, however the user account it's currently running under is a member of the Administrators group.

Apr 18, 2012 at 10:35 PM

I'm also getting this error.  

I'm hoping to use this within a web app running under IIS App Pool Identity so I need to be able to create these scheduled tasks as an unprivileged user.  Will this library be able to do this?  Is it even possible with completely compromising my servers security?

Apr 19, 2012 at 12:22 AM

In order to register a ServiceAccount, like SYSTEM, the connected user of the TaskService must have permissions to use that account. Under ASP.NET, the thread typically run under a special account that does not have those permissions. Check the thread for more information on permissions required to register tasks.