Using Delegation in Scheduled Tasks

This blog is about the ability in Windows 7 and Windows Server 2008 R2 to apply a SID to every scheduled task and use that SID to apply permissions elsewhere in the Operating System.

Services already have this feature from Vista and newer. The idea is the same; take the simple name for the service (or in that case of scheduled tasks in 7/R2 the path to the scheduled task) and compute a predictable SID based on that name. Have a look at the permissions applied to C:\Windows\System32\LogFiles\Firewall to see this in action. On the permissions of this folder, there is an ACE for a “group” called MpsSvc, which is the short name for the Windows Firewall service. In this way, even though the service is set to start as “Local Service”, not all other services which also run as this same account can see into the Firewall logs, only the firewall service itself has access.

So every scheduled task can have a SID computed for it – this new feature is described here:

And the way to locate what the predicable SID for a given service name is to run:

schtasks /showsid /TN “TaskName”

With this SID, you can now assign permissions to resources. For example, you could use icacls to apply permission to a folder, below we are granting an NT TASK (SID starts with S-1-5-87) modify permission to the folder C:\SomeFolder:

icacls C:\SomeFolder /grant *S-1-5-87-xxxx-yyyy-zzzz:(M)

Now, if you go and setup your task in the GUI, and run these commands, you will see icacls report back:

No mapping between account names and security IDs was done.

What went wrong?

First you need to make sure that the scheduled task is configured for Windows 7 or Windows Server 2008 R2 and is using either “Network Service” or “Local Service”:


Then you need to make the task use the Unified Scheduling Engine so that it registers the SID with the list of “well known SIDs” for the system. But there is no check-box for this setting, and it is disabled by default. What to do?

Export your task as an XML file, locate the line which reads:


And change that “False” to “True”:


With that changed, remove your task and import the XML file you modified above.

Because the SID is a predicable calculation of the path to the task, so long as you recreate the task with the same name and in the same folder, the SID will remain the same and your icacls command will now work as expected, and only that scheduled task will have access to the file or folder to specify.

The Unified Scheduling Engine leverages the Unified Background Process Manager (UBPM), which is described further here:

Comments (4)
  1. Jay Adams says:

    I wish Microsoft had added this type of functionality to v1.0 of the Task Scheduler so previous versions could take advantage of it. I'm actually developing a tool that will let you delegate rights to start and stop scheduled tasks using a centralized web based management tool. It's called System Frontier ( Since there haven't been any comments before mine, my first guess is that most people are just handing out local admin access to solve this problem. That's definitely asking for trouble when it comes time to report on appropriate access.

  2. Leecher says:

    Thanks for nothing Jay.

  3. eryk sun says:

    A service can run as its virtual account, and the system allows assigning rights and privileges to this virtual account. Task SIDs should also be virtual accounts under which the task can run with specific rights and privileges. For example, if a task runs as the “LOCAL SERVICE” well-known group, then by default it isn’t allowed to create symbolic links. I shouldn’t have to grant this privilege to “LOCAL SERVICE”.

    1. @Eryk Sun: You have been able to do this since Windows Vista/2008. Run sc.exe showsid
      You get back a predictable hash of the service short name which you can assign permissions and rights to.
      e.g. Imagine I had a service with a short name of ErykSun. The predictable hash is:
      S-1-5-80-3358953203-3575185467-777747353-973019157-3997827419 (try it on your own machine, it matches).
      I can then use GPOs to assign rights to this SID, or cacls.exe to assign file/folder permissions to it.
      In that way only that service has those rights, not every service which is running as the same account as ErykSun (e.g. LOCAL SERVICE)

Comments are closed.

Skip to main content