I have some code that uses the Windows Server 2008 task object model to invoke a scheduled task on a remote server:
var scheduler = new TaskSchedulerClass();
scheduler.Connect(ServerName, username, domain, password);
var folder = scheduler.GetFolder(FolderName);
var task = folder.GetTask(TaskName);
task.Run(null);
This works well if the user account is a member of the Administrators group on that server but I am trying to find the minimum set of permissions to invoke the task. I tried giving the account full control of the \windows\system32\tasks folder but that did not help. So far the only group that works is Administrators. All other accounts throw this error:
System.UnauthorizedAccessException: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)) at TaskScheduler.TaskSchedulerClass.Connect(Object serverName, Object user, Object domain, Object password)
Note that I do not need to create tasks or change anything about tasks. The code only needs to invoke tasks that have already been defined.
As background, this is the article that inspired my code but as you see I am not doing any of the creation/modification bits: link text