also how can you tell if it is running, enabled/disabled, etc.?
+3
A:
There is a Task Scheduler API that you can use to access information about tasks. (It is a com library, but you can call it from C# using pinvokes)
There is an article on codeproject that provides a .net wrapper for the API.
Simon P Stevens
2009-08-06 22:44:43
checked out that codeProject wrapper. It works great. I'm really surprised that there are no scheduleTask objects in the .net framework!
KevinDeus
2009-08-07 18:00:50
A:
btw, IRT my accepted solution, here is the CodeProject wrapper code (see http://www.codeproject.com/KB/cs/tsnewlib.aspx ) needed to verify that a scheduledTask exists
I use this in an Integration test so the Assert is NUnit..
public static void VerifyTask(string server, string scheduledTaskToFind)
{
ScheduledTasks st = new ScheduledTasks(server);
string[] taskNames = st.GetTaskNames();
List<string> jobs = new List<string>(taskNames);
Assert.IsTrue(jobs.Contains(scheduledTaskToFind), "unable to find " + scheduledTaskToFind);
st.Dispose();
}
to check if it is enabled, you can do the following:
Task task = st.OpenTask(scheduledTaskToFind);
Assert.IsTrue(task.Status != TaskStatus.Disabled);
KevinDeus
2009-08-07 18:32:00