This project has moved. For the latest updates, please go here.

Looping through tasks

Sep 17, 2008 at 8:31 PM

First off, thank you for making a 2.0 wrapper!

I am having trouble figuring out how to loop through all the tasks on my computer

Dim tc As TaskCollection


For Each t As Task In tc



    If t.Name.ToLower = "daily task.job" Then







End If





Since there is no way of accessing the new method of TaskCollection,  tc is always nothing
 What am I overlooking ?

Sep 22, 2008 at 6:24 PM
Try this -


TaskService ts = new TaskService();
TaskFolder taskFolder = _ts.GetFolder(@"\");
foreach (Task t in taskFolder.Tasks)
  TaskDefinition td = task.Definition;
  if ( == "whatever")


Sep 22, 2008 at 9:12 PM

Thank you very much.

Now I have run into another question that hopefully you can answer.

In the previous version of the TaskScheduler, you were able to set a username and password with SetAccountInformation(_accountName, _accountPassword)

All I was able to find was a Principle.UserId. If I set the Principle.LogonType = TaskLogonType.Password. How do I specify a password for the task?



Sep 23, 2008 at 12:26 PM
Can't help you there.  Though I do know that the test program that comes with the project adds a task.
Oct 14, 2008 at 11:51 PM
You can now do this through the TaskFolder.RegisterTaskDefinition method by supplying a UserId, password and setting the TaskLogonType to either InteractiveTokenOrPassword or Password.