Page 1 of 1

Run a task every hour in vista

Posted: Fri May 16, 2008 9:37 am
by famini
Hello,
I'd like to schedule a task in Vista but I have some problems.

This task must be executed every hour between 0 AM and 12PM.

For XP I use :

Code: Select all

Task.Triggers[0].StartDate := Date();
Task.Triggers[0].StartTime := 0;
Task.Triggers[0].Duration := 1440; // 24 hours
Task.Triggers[0].Interval := 60; // every hour
But this doesn't work in Vista

How can I do this without change property TaskScheduler1Only to True ?

Thanks,

Posted: Fri May 16, 2008 11:41 am
by isiticov
Hello,

There is a problem with this under Vista. We will fix this in forthcoming 2.0.1 release.

Posted: Fri May 16, 2008 12:14 pm
by famini
Thank you for your answer isiticov.

By searching in the component source I have found a solution to my problem by setting the properties "Interval" & "Duration" of the IRepetitionPattern interface.

Here is the code :

Code: Select all

  if TaskScheduler.RunningVistaOrLater then begin
    Task.Triggers[0].GetVistaTrigger().Repetition.Interval := 'PT1H'; // 1 hour
    Task.Triggers[0].GetVistaTrigger().Repetition.Duration := 'PT24H'; // 24 hours
  end;
Regards

Posted: Fri May 16, 2008 3:04 pm
by isiticov
Yes, exactly. These fields shall to be used.