Reputation: 1402
How to get triggers information from the TaskService
object for the scheduled tasks?
StringBuilder sb = new StringBuilder();
TaskService st = new TaskService();
var tasks = st.RootFolder.GetTasks();
foreach (Microsoft.Win32.TaskScheduler.Task task in tasks)
{
sb.Append(task.Name+",");
sb.Append(task.someValueHere <<<---
sb.Append(task.LastRunTime + ",");
sb.Append(task.NextRunTime.ToString()+" ; ");
}
st.Dispose();
Upvotes: 0
Views: 1739
Reputation: 45135
You need to access the Definition
and then the Triggers
. For example:
foreach (var task in tasks)
{
//...
foreach (var trigger in task.Definition.Triggers)
{
//...access trigger properties here.
}
}
Upvotes: 1