troubleshooting Question

Delphi create and access TaskScheduler subfolder

Avatar of Stef Merlijn
Stef MerlijnFlag for Netherlands asked on
5 Comments2 Solutions337 ViewsLast Modified:

I'm trying to create subfolder in the TaskScheduler (using Delphi) and create schedules for my application inside the subfolder.
For TaskScheduler-access I use this EE-example.

To create a subfolder I found method TaskFolder.CreateFolder('\MyFolder', ?sddl?);.
Here sddl (=security descriptor associated with the folder) must be set, but I have no idea how to set it correctly.

So as a workaround I tried to create the folder "MyFolder" directly into folder "C:\Windows\System32\tasks\".
The folder is actually created by my application, but the folder is not visible inside Windows TaskScheduler.

procedure TForm1.Button1Click(Sender: TObject);
var ts : TTaskScheduler;
    tf: ITaskFolder;
  CoInitialize(nil);                    // uses ActiveX
  ts := TTaskScheduler.Create(Self);
    ts.AutoConnect := True;
    if ts.Connected then

      // ts.GetFolder('\MyFolder', ?sddl? );   << THIS DOESN'T WORK
      // As a workaround I create the folder myself.
      // System32 is changed into SysNative, as otherwise the folder would be created in SysWOW64.

      if DirectoryExists('C:\Windows\SysNative\tasks\MyFolder\') then
        tf := ts.GetFolder('\MyFolder')   // << THIS GIVES AN UNKNOWN ERROR
        tf := ts.GetFolder('\');
How can I create a subfolder for taskscheduler in order to add my application's schedules inside that subfolder?
Sinisa Vuk
Software architect
Join our community to see this answer!
Unlock 2 Answers and 5 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros