Duration

This forum is designated to discuss SiComponents Scheduling Agent.
Post Reply
Ted Tripp
Posts: 5
Joined: Fri Aug 18, 2006 2:04 am

Duration

Post by Ted Tripp »

Hi,

Trying to figure out how this works and am almost there.

I am having a problem with the following line:
Task->Triggers->Items[0]->Duration
which would appear to effect the "Repeat Task" value (true/false) in the actual task scheduler.

If I simply create a new task using the "Scheduled Task Wizard" and make it Daily, the "Repeat Task" is disabled in the Advanced screen. This is the way I want it, however I can't seem to make this happen using the component.

How do I disable the "Repeat Task"? If I remove the Duration value I get a message that the Parameter is Incorrect...

Thanks
isiticov
Site Admin
Posts: 2383
Joined: Thu Nov 21, 2002 3:17 pm

Post by isiticov »

Hi,

You don't need to use Duration property at all in order to create task with disabled "Repeat Task" group box in advanced settings. So just use something like the following code to create your task:

Code: Select all

procedure TMainForm.Runnotepadexeeachdayat09001Click(Sender: TObject);
var
   TriggerDetails: TTriggerDetails;
   ST: TSystemTime;
begin
  try
    with Scheduler.CreateNewItem(Format('New task %d', [GetTickCount])) do
    begin
      ApplicationName := 'notepad.exe';
      Triggers.Add;
      Triggers[0].TriggerType := ttDaily;
      // create start time data
      DateTimeToSystemTime(Now, ST);
      ST.wHour := 9;
      ST.wMinute := 0;
      ST.wSecond := 0;
      ST.wMilliseconds := 0;
      Triggers[0].StartTime := SystemTimeToDateTime(ST);
      Triggers[0].BeginDate := Date;
      Triggers[0].EndDate := Date + 30; // will be executed during 1 month
      Triggers[0].HasEndDate := True;
      TriggerDetails.Daily.DaysInterval := 1;
      Triggers[0].Details := TriggerDetails; // trigger details must be changed only this way
      // could be used UpdateTriggers and Save
      Triggers.UpdateTriggers;
      // to set-up a task for user w/o password
      // use the code below
      {Flags := Flags + [tfRunOnlyIfLoggedOn];
      SetAccountInformation(GetOSUser, '');}
      Save;
      // or just Deactivate(True)
      //Deactivate(True);
  end;
  finally
    acRefresh.Execute;
  end;
end;
Please let me know if this helps.

P.S. This code is from demo project delivered with VCL Scheduling Agent.
Best regards,
Igor Siticov.
Ted Tripp
Posts: 5
Joined: Fri Aug 18, 2006 2:04 am

Post by Ted Tripp »

But if I remove the duration, I get "...EOleSysError with message 'The parameter is incorrect'..."
Ted Tripp
Posts: 5
Joined: Fri Aug 18, 2006 2:04 am

Post by Ted Tripp »

Never mind. After removing Task->Triggers->Items[0]->Interval as well, everything works fine.
Post Reply