View previous topic :: View next topic |
Author |
Message |
Ted Tripp
Joined: 18 Aug 2006 Posts: 5
|
Posted: Sat Aug 19, 2006 11:20 pm Post subject: Duration |
|
|
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 |
|
 |
isiticov Site Admin
Joined: 21 Nov 2002 Posts: 2129
|
Posted: Mon Aug 21, 2006 7:46 am Post subject: |
|
|
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 |
|
 |
Ted Tripp
Joined: 18 Aug 2006 Posts: 5
|
Posted: Mon Aug 21, 2006 8:19 pm Post subject: |
|
|
But if I remove the duration, I get "...EOleSysError with message 'The parameter is incorrect'..." |
|
Back to top |
|
 |
Ted Tripp
Joined: 18 Aug 2006 Posts: 5
|
Posted: Mon Aug 21, 2006 8:25 pm Post subject: |
|
|
Never mind. After removing Task->Triggers->Items[0]->Interval as well, everything works fine. |
|
Back to top |
|
 |
|