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

Looping through tasks

Sep 17, 2008 at 9:31 PM
Hello,

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

 

 

 

MsgBox("found")

 

 

End If

 

 

 

Next

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

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

 

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

 

Sep 22, 2008 at 10: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?

Thanks,

Ryan

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