Hi,
I am running the code below on Windows 7 (built using Delphi 7) but get the error "Task 'Maximus_20100420223644' is not activated." when trying to execute line
"Task.Flags := Task.Flags + [tfRunOnlyIfLoggedOn, tfDeleteWhenDone];". The code works fine on Windows XP but not Windows 7.
Do you know what I am doing wrong?
CoInitialize(nil);
TaskScheduler := nil;
TaskScheduler := TTaskScheduler.Create(nil);
TaskScheduler.Active := True;
Task := TaskScheduler.CreateNewItem('Maximus_' + DateTimeToMaximusDateTime);
Task.Triggers.Add(ttOnce);
Task.Triggers[0].StartTime := Time;
Task.Triggers[0].BeginDate := Date;
Task.Triggers[0].Enabled := true;
Task.Triggers.UpdateTriggers;
Task.ApplicationName := 'Blaa';
Task.WorkingDirectory := ExtractFilePath(BlaaFilename);
Task.Parameters := '';
Task.SetAccountInformation(FUsername, FPassword);
Task.Flags := Task.Flags + [tfRunOnlyIfLoggedOn, tfDeleteWhenDone];
Task.Save;
Task.Run;
finally
TaskScheduler.free;
CoUnInitialize;
end;
Thanks
Jeff
Error: Task is not activated
Hello,
Please use Task.VistaFlags property under Windows Vista and later and Task.Flags for earlier versions. To detect the running OS you can use:
Please use Task.VistaFlags property under Windows Vista and later and Task.Flags for earlier versions. To detect the running OS you can use:
Code: Select all
if (not Scheduler.RunningVistaOrLater) then...
Best regards,
Igor Siticov.
Igor Siticov.
-
- Posts: 3
- Joined: Tue Mar 23, 2010 1:30 am