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
Duration
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:
Please let me know if this helps.
P.S. This code is from demo project delivered with VCL Scheduling Agent.
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;
P.S. This code is from demo project delivered with VCL Scheduling Agent.
Best regards,
Igor Siticov.
Igor Siticov.