SchTasks.exe to create a task folder

There doesn't appear to be any way to do this via SchTasks.exe. If you run SchTasks.exe /Create /? at a command prompt, it shows you the available options. Creating a folder for the task doesn't show up as one of them, as far as I can see.

You might be able to do this via the ITaskScheduler interface. See this question for a discussion of the difference, and a link to a library that encapsulates the interface. (I haven't seen the library and don't know anything about it; it just appears as the solution based on the accepted answer to the linked question.)


It's an old thread but I found no answer elsewhere so I wrote a little powershell script which copies the task to a new folder and rewrites the UserId if wanted. Don't forget to delete the old tasks manually.

Get-ScheduledTask | ? {$_.Taskpath -ieq "\FROM"} | % {
    $oTask = $_
    [XML]$TaskXML = Export-ScheduledTask -TaskName $oTask.TaskName

    #$TaskXML.GetElementsByTagName("UserId")[0].InnerText="SYSTEM"

    Register-ScheduledTask -TaskName $oTask.TaskName -TaskPath "\TO" -Xml $TaskXML.InnerXML
}

few trials and solved the problem; the key is using "\" in the task name. Sample schtask.exe command line,

schtasks /create /xml "MyTask.xml" /tn "My Task Folder\My New Task"

creates a new task folder My Task Folder and creates a new task My New Task under the new folder

If the task needs to get created under an existing folder, try

schtasks /create /xml "MyTask.xml" /tn "Existing Task Folder\My New Task"

creates a new task My New Task under an existing task folder Existing Task Folder