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 

Task won't run

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



Joined: 18 Sep 2007
Posts: 2

PostPosted: Tue Sep 18, 2007 2:06 pm    Post subject: Task won't run Reply with quote

Hello

I am trying to get my application to create/update a task in the scheduler, to run at a user set time of the day.

However, my task never runs and task Scheduler reports "Could not start".

My schedule procedure follows, and is mostly copied from the help file.

Can anyone see what I have done wrong?

Thanks

Vert


/*==============Code below======================*/

procedure SetSched(hour, minutes: integer);
var n : integer;
task : ttaskitem;
ST : TSystemTime;
trigger : ttrigger;
triggerdetails : ttriggerdetails;
taskscheduler1: ttaskscheduler;
begin
taskscheduler1:=ttaskscheduler.create(nil);
try
task:=nil;
taskscheduler1.Open;
taskscheduler1.Refresh;

for n:=0 to taskscheduler1.Count-1 do
begin
if taskscheduler1.Items[n].name='Notepad' then
begin
task:=taskscheduler1.Items[n];
task.Activate;
task.Triggers.clear;
end;
end;

if task=nil then
begin
task:=TaskScheduler1.CreateNewItem('Notepad');
end;

if task=nil then exit;

with task do
begin

ApplicationName:='c:\windows\system32\notepad.exe';
Flags:=[tfRunOnlyIfLoggedOn];

DateTimeToSystemTime(now, ST);
ST.wMinute:=minutes;
ST.wSecond:=0;
ST.wMilliseconds:=0;
ST.wHour:=Hour;
Trigger:=task.Triggers.Add;
Trigger.triggertype:=ttDaily;
Trigger.BeginDate:=date;
Trigger.StartTime:=SystemTimeToDateTime(ST);

TriggerDetails.Daily.DaysInterval:=1;

Trigger.Details:=TriggerDetails;

Triggers.UpdateTriggers;

Save;
end;
taskscheduler1.close;
finally
taskscheduler1.free;
end;

end;
Back to top
View user's profile Send private message
Vertuas



Joined: 18 Sep 2007
Posts: 2

PostPosted: Tue Sep 18, 2007 2:21 pm    Post subject: Additionally Reply with quote

Just been experimenting.

If i select run from the scheduler i get the same error message.

If i then open th task, change something (i deleted the e from the end of .exe, re typed it, then clicked ok), then try and run the task, it then runs.

I suspect i have missed a setting that windows is updating for me.

Thanks

Vert
Back to top
View user's profile Send private message
isiticov
Site Admin


Joined: 21 Nov 2002
Posts: 2102

PostPosted: Tue Sep 18, 2007 4:05 pm    Post subject: Reply with quote

Hello,

I can suppose that you need to set user name and password for task using SetAccountInformation() method.
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