Task Renaming Revisited

This forum is designated to discuss SiComponents Scheduling Agent.
Post Reply
CarlDippel
Posts: 15
Joined: Thu Nov 13, 2003 7:41 pm
Location: LI, NY
Contact:

Task Renaming Revisited

Post by CarlDippel »

I'm trying to rename task a1 by saving it as A12 and deleting a1. The A12 task is created in the current directory. How can I create it in the Scheduled Tasks directory? -Carl

Code: Select all

var
  Task:TTaskItem;
begin
  TaskScheduler1.Open;
  Task:=TaskScheduler1.ActivateTask('a1');
  Task.Activate;
  Task.Save('A12');
  Task.Deactivate(False);
  Task.Free;
  TaskScheduler1.DeleteTask('a1');
  TaskScheduler1.Close;
end;
-- Carl Dippel carl@dippel.us www.dippel.us/carl --
Anonymity negates sincerity.
isiticov
Site Admin
Posts: 2383
Joined: Thu Nov 21, 2002 3:17 pm

Post by isiticov »

This is strange how you was able to save task under current folder. But in that case you can try the following code as alternative:

Code: Select all

  Task := Scheduler.ActivateTask('test_1'); 
  if Task = nil then exit; 
  Task.Activate; 
  sOldName  := Task.CurFile; 
  Task.Deactivate(False); 
  sNewName := ExtractFilePath(sOldName) + 'test_3.job'; 
  if Windows.CopyFile(PChar(sOldName), PChar(sNewName), False) then 
    Scheduler.DeleteTask('test_1');  
CarlDippel
Posts: 15
Joined: Thu Nov 13, 2003 7:41 pm
Location: LI, NY
Contact:

Post by CarlDippel »

This is strange how you was able to save task under current folder
I'm using WinXP Pro with an NTFS HD.
But in that case you can try the following code as alternative:
It worked like a charm. Thanks a million!

BTW I used MoveFile instead of CopyFile|DeleteTask. Do you for see any problems with that change? -Carl

-- Carl Dippel carl@dippel.us www.dippel.us/carl --
Anonymity negates sincerity.
isiticov
Site Admin
Posts: 2383
Joined: Thu Nov 21, 2002 3:17 pm

Post by isiticov »

CarlDippel wrote:
BTW I used MoveFile instead of CopyFile|DeleteTask. Do you for see any problems with that change?
No, there is no difference in methods.
Post Reply