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 

Error: Task is not activated

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



Joined: 23 Mar 2010
Posts: 3

PostPosted: Tue Apr 20, 2010 12:48 pm    Post subject: Error: Task is not activated Reply with quote

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


Joined: 21 Nov 2002
Posts: 2102

PostPosted: Wed Apr 21, 2010 10:01 am    Post subject: Reply with quote

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:
Code:
if (not Scheduler.RunningVistaOrLater) then...
Back to top
View user's profile Send private message
jeffreysadler



Joined: 23 Mar 2010
Posts: 3

PostPosted: Wed Apr 21, 2010 12:09 pm    Post subject: Reply with quote

I tried your suggested changes and it now works.

Thank you.
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