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

Displayed Tasks not showing correct Status nor NextRunTime

Jul 18, 2012 at 6:51 PM

We have tasks listed in a folder on our Windows Server 2008 R2, and can loop through tasks, however, items aren't showing correct information.


NextRunTime; // it's showing 12/30/1899 12:00:00 AM

Status // it's showing 'Ready' even while its 'Running' on Task Scheduler


Our setup:
Task Scheduler > Reports > DailyExcelReport1
Task Scheduler > Reports > DailyExcelReport2
Task Scheduler > Reports > DailyExcelReport3
and so on...

To access it via code:

var State = "";
var NextRunTime;

using (var taskService = new TaskService("servername", "username", "DOMAIN", "password1"))
  if (taskService.Connected)
    var tasks = taskService.GetFolder("Reports").Tasks;�
    foreach (var task in tasks)
      State = task.State.ToString(); // it's showing 'Ready' even while its 'Running' on Task Scheduler
      NextRunTime = task.NextRunTime; // it's showing 12/30/1899 12:00:00 AM
On the Task Scheduler:

Details for DailyExcelReport Task --
Weekly; At 7:00 am every Mon, Tues, Wed, Thurs, Fri; Status: enabled

Any ideas?


Jul 24, 2012 at 6:40 PM


Aug 3, 2012 at 5:29 PM

Found the problem... I had assigned permissions to C:\Tasks, but on this machine the Tasks are stored at C:\Windows\System32\Tasks -- once I assigned the folder the correct permissions, then it worked.  Sorry for the wild goose chase.