Setting Enabled on task returns Access Denied?

Mar 28, 2011 at 10:52 AM

Hi there,

 

Can anyone help?

 

I am attempting to change the Enabled property of a task. I get the task and sure enough it is set to True. I try and set it to false and i get the error.

 

Here is my method and error, basically task is the correct object.

 

 public void DisableTask(string name)
        {
            var task = this.GetTask(name, this.GetDefaultFolder());
            try
            {
                task.Enabled = false;
            }
            catch (Exception e)
            {
                
                throw;
            }
 
        }

Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))


   at Microsoft.Win32.TaskScheduler.V2Interop.IRegisteredTask.set_Enabled(Boolean value)
   at Microsoft.Win32.TaskScheduler.Task.set_Enabled(Boolean value)
   at


Coordinator
Mar 28, 2011 at 5:14 PM

Sounds like a permissions problem. Please see http://taskscheduler.codeplex.com/discussions/247469 for some further detail on what permissions need to be in place.