EDN Admin
Well-known member
Hi all,<br/>
I am working on a WPF application. I am trying to read task from Windows "Scheduled Tasks" using c#.<br/>
The below code is giving " Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)) " when
UAC is high in a system.
//Get a ScheduledTasks object for the local computer.<br/>
ScheduledTasks st = new ScheduledTasks();<br/>
// Open a task were interested in<br/>
Task task = st.OpenTask("OnlineBackupManager"); <br/>
/// <summary><br/>
/// Opens the task with the given <paramref name="name" />. An open task holds COM interfaces<br/>
/// which are released by the Tasks Close() method.<br/>
/// </summary><br/>
/// <remarks>If the task does not exist, null is returned.</remarks><br/>
/// <param name="name Name of task to open.</param><br/>
/// <returns>An instance of a Task, or null if the task name couldnt be found.</returns><br/>
public Task OpenTask(string name) {<br/>
try {<br/>
object o;<br/>
its.Activate(name, ref ITaskGuid, out o); // From here the exception ( Access is denied. (Exception from HRESULT: 0x80070005 //(E_ACCESSDENIED)))
is thrown when UAC is set high for a particular system.<br/>
ITask iTask = (ITask)o;<br/>
return new Task(iTask, name);<br/>
}<br/>
catch {<br/>
return null;<br/>
}<br/>
}<br/>
I am not able to find any proper solution. How can I read task from Windows "Scheduled Tasks" pro-grammatically when UAC is set high ?
<br/>
<br/>
<br/>
View the full article
I am working on a WPF application. I am trying to read task from Windows "Scheduled Tasks" using c#.<br/>
The below code is giving " Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)) " when
UAC is high in a system.
//Get a ScheduledTasks object for the local computer.<br/>
ScheduledTasks st = new ScheduledTasks();<br/>
// Open a task were interested in<br/>
Task task = st.OpenTask("OnlineBackupManager"); <br/>
/// <summary><br/>
/// Opens the task with the given <paramref name="name" />. An open task holds COM interfaces<br/>
/// which are released by the Tasks Close() method.<br/>
/// </summary><br/>
/// <remarks>If the task does not exist, null is returned.</remarks><br/>
/// <param name="name Name of task to open.</param><br/>
/// <returns>An instance of a Task, or null if the task name couldnt be found.</returns><br/>
public Task OpenTask(string name) {<br/>
try {<br/>
object o;<br/>
its.Activate(name, ref ITaskGuid, out o); // From here the exception ( Access is denied. (Exception from HRESULT: 0x80070005 //(E_ACCESSDENIED)))
is thrown when UAC is set high for a particular system.<br/>
ITask iTask = (ITask)o;<br/>
return new Task(iTask, name);<br/>
}<br/>
catch {<br/>
return null;<br/>
}<br/>
}<br/>
I am not able to find any proper solution. How can I read task from Windows "Scheduled Tasks" pro-grammatically when UAC is set high ?
<br/>
<br/>
<br/>
View the full article