Click here to Skip to main content
13,003,589 members (62,113 online)
Rate this:
Please Sign up or sign in to vote.
Hey there,

I want to create Tasks on a server using an application on computers.

To be abled to work with tasks iam using the Task Scheduler Class Library from this article:

A New Task Scheduler Class Library for .NET[^]

To impersonate i use this:
User Impersonation in .NET[^]

To test it I wrote this simple code to run it on my computer:
ImpersonateUser iU = new ImpersonateUser();
iU.Impersonate("servername", "accountname", "password");
//the account has admin privileges
    ScheduledTasks st = new ScheduledTasks("servername");
    foreach (string a in st.GetTaskNames())
catch (Exception e)

After the line
ScheduledTasks st = new ScheduledTasks("servername");

I get an Access Denied Exception.

Does anyone know why?

Thanks in advance.
Posted 13-May-13 2:48am
David_Wimbley 13-May-13 10:06am
Does your username/pass that you are using for impersonation have proper permissions in the first place to mess with the task scheduler?
ANDiyo 14-May-13 2:17am
Yes. I can login with the username/pass on the server and iam abled to create tasks there manually.
Kschuler 14-May-13 17:15pm
What is the exact wording of the exception? Any more info there?
ANDiyo 15-May-13 5:12am
0x80070005 (E_ACCESSDENIED)
Kschuler 15-May-13 8:46am
Did you try googling that? Because I did and there were ALL KINDS of possible fixes you could try.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web01 | 2.8.170626.1 | Last Updated 13 May 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100