Page 1 of 1
Task Renaming Revisited
Posted: Sun Jun 20, 2004 10:59 am
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 --
Posted: Mon Jun 21, 2004 6:57 am
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');
Posted: Mon Jun 21, 2004 12:42 pm
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 --
Posted: Mon Jun 21, 2004 8:10 pm
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.