Normally I would have posted this on StackOverflow, but it's currently down!
Normally I would have posted this on StackOverflow, but it's currently down!
Has anybody tried creating tasks using JEDI's TJclTaskSchedule?
The following code works perfectly on Windows 7 and earlier, but fails on Windows 8 with the error "The task XML is missing a required element or attribute". Anyone got any idea why?
unit Unit13;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls,
JclTask, MSTask;
type
TForm13 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form13: TForm13;
implementation
{$R *.dfm}
procedure TForm13.Button1Click(Sender: TObject);
var
TaskSchedule: TJclTaskSchedule;
Task: TJclScheduledTask;
begin
TaskSchedule := TJclTaskSchedule.Create('');
try
// This works on Windows 7 and earlier, but fails on Windows 8 with the error:
// "The task XML is missing a required element or attribute"
Task := TaskSchedule.Add(edtTaskname.Text);
finally
FreeAndNil(TaskSchedule);
end;
end;
end.
Has anybody tried creating tasks using JEDI's TJclTaskSchedule?
The following code works perfectly on Windows 7 and earlier, but fails on Windows 8 with the error "The task XML is missing a required element or attribute". Anyone got any idea why?
unit Unit13;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls,
JclTask, MSTask;
type
TForm13 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form13: TForm13;
implementation
{$R *.dfm}
procedure TForm13.Button1Click(Sender: TObject);
var
TaskSchedule: TJclTaskSchedule;
Task: TJclScheduledTask;
begin
TaskSchedule := TJclTaskSchedule.Create('');
try
// This works on Windows 7 and earlier, but fails on Windows 8 with the error:
// "The task XML is missing a required element or attribute"
Task := TaskSchedule.Add(edtTaskname.Text);
finally
FreeAndNil(TaskSchedule);
end;
end;
end.
Sounds like the task XML which the JCL generates is not compatible with Windows 8 - i.e. missing a required field for Win8.
ReplyDeleteCheck specifications on MSDN and update JCL code?
Lars Fosdal - JCL doesn't generate the XML. It uses COM:
ReplyDeleteprocedure TJclScheduledWorkItem.Save;
begin
OleCheck((FScheduledWorkItem as IPersistFile).Save(nil, True));
end;
That is strange... If MS obsoleted the COM interface, they must have screwed up. If you export the specific com interfaces from a W7 vs a W8 machine - are there any differences?
ReplyDeleteLars Fosdal - Exactly, it's very strange.
ReplyDeleteStackOverflow is back up. I've posted this question: http://stackoverflow.com/questions/14811932/error-when-creating-a-task-using-jedis-tjcltaskschedule-under-windows-8
TLama points out that v.1 of the interface is obsolete since Vista. It's not unlikely that Windows 8 no longer supports it fully, and require v.2.
ReplyDeleteI think this must be the case. I think I'll convert my code to use schtasks.exe instead of relying on JEDI/COM.
ReplyDeleteHow hard is it to export the v.2 IF ? I guess that will last a few years? Calling an .exe file seems like a potential security issue.
ReplyDeleteAt first glance, the V2.0 API looks a lot more involved than V1.0. How is calling the exe a security risk? It's a system file and any changes to the tasks require elevation.
ReplyDeleteIn future, I'd post this on the Jedi Bug Tracker instead.
ReplyDeleteWarren Postma - I have already posted it on the JEDI bug tracker.
ReplyDelete