This project has moved and is read-only. For the latest updates, please go here.

Access Denied Reading a Task on Windows 2008

Jan 30, 2012 at 4:19 PM

I am getting an Access Denied error when trying to read a task on a Windows Server 2008.  When I run my C# program from my Windows 7 laptop I do not get the error.  When I run the C# code from a Windows 2003 server, I get the error.  I am using credentials that are Administrator on both the Windows 2003 and 2008 servers.  The 2003 server can successfully access and populate the TaskService object, so the error is just on the Task population.  I have tried different task jobs on the 2008 server and get the same error.  However, those same jobs can be read when they are on a 2003 server.

I have tried both supplying credentials within the code and using no credentials in the code, either way errors.  I have also run the code as a service and as a stand alone app on the 2003 server, with Admin credentials, and it still errors getting a Task on 2008 server.  Is there something different about accessing jobs on 2008 from a 2003 server? 


Jan 30, 2012 at 7:22 PM

This is one of those scenarios where Microsoft's choice to complete change the library between those releases bites you. Windows 2003 only has the V1 library installed and therefore all access to other systems is limited to V1 tasks and security. Windows 2008, by default and like Win7, will use the V2 library to create tasks. One thing you can try is to use the constructor for TaskService and always force to V1. Then all tasks created should be compatible regardless of where they're accessed from. Please post back your findings.

Jan 31, 2012 at 3:09 PM

Thanks for the response; that is good information and makes sense.  I created a task on the 2008 server from a C# program and forced V1.  It was successfully accessed from the program running on the 2003 server as you predicted.  The interesting thing is that when the job is read from the program running on Windows 7, the job's HighestSupportedVersion = 1.3, and when read from server 2003 that same job's HighestSupportedVersion is 1.1.  Also, the program running on Windows 7 and reading jobs from server 2003 show HighestSupportVersion = 1.1.  I'm not sure I understand what is going on with the 1.1 and 1.3 on the same job so if you have an explanation I would be interested to hear it.

My plan is to simply run my monitoring program from a 2008 server.  In my case I am reading existing jobs and not creating new ones.  Thank you for creating this excellent code for use with Windows Task Scheduler.