SiComponents Home Page SiComponents Forums
Here you will be able to get help and share your experience
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Duration

 
Post new topic   Reply to topic    SiComponents Forums Forum Index -> VCL Scheduling Agent
View previous topic :: View next topic  
Author Message
Ted Tripp



Joined: 18 Aug 2006
Posts: 5

PostPosted: Sat Aug 19, 2006 11:20 pm    Post subject: Duration Reply with quote

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
Back to top
View user's profile Send private message
isiticov
Site Admin


Joined: 21 Nov 2002
Posts: 2096

PostPosted: Mon Aug 21, 2006 7:46 am    Post subject: Reply with quote

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:
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.
Back to top
View user's profile Send private message
Ted Tripp



Joined: 18 Aug 2006
Posts: 5

PostPosted: Mon Aug 21, 2006 8:19 pm    Post subject: Reply with quote

But if I remove the duration, I get "...EOleSysError with message 'The parameter is incorrect'..."
Back to top
View user's profile Send private message
Ted Tripp



Joined: 18 Aug 2006
Posts: 5

PostPosted: Mon Aug 21, 2006 8:25 pm    Post subject: Reply with quote

Never mind. After removing Task->Triggers->Items[0]->Interval as well, everything works fine.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    SiComponents Forums Forum Index -> VCL Scheduling Agent All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by p h p B B  © 2001, 2005 p h p B B  Group