Click here to Skip to main content
11,789,512 members (38,386 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: C# .NET TaskScheduler
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 at 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 at 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 at 14-May-13 17:15pm
What is the exact wording of the exception? Any more info there?
ANDiyo at 15-May-13 5:12am
0x80070005 (E_ACCESSDENIED)
Kschuler at 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
0 OriginalGriff 954
1 Maciej Los 765
2 KrunalRohit 666
3 CPallini 606
4 Richard MacCutchan 420

Advertise | Privacy | Mobile
Web03 | 2.8.1509028.1 | Last Updated 13 May 2013
Copyright © CodeProject, 1999-2015
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