I have some tasks in the Task Scheduler on Windows 2008 R2. I created them as the admin and I'm logged in as the admin. I have no easy way to rename the tasks. The only way I can is to export the task config to a XML file and re-import to a new task, change the name there, then delete the old task. Is there an easier way?
Congratulations! You've come up against a problem that has stumped many a Windows user/admin. No, you cannot rename a task except for exporting, renaming and importing again. Yes, it's rather silly. Perhaps an enterprising scripter could create a simple PowerShell script that automates this, but until then, you're stuck with your export/import two-step. Sorry. =(
(You also can't rename a task folder after you've created it.)
Not the best way but can be a life saver.
Tasks are stored in
C:\Windows\System32\Tasks in XML format importable using
schtasks.exe. As Weasly told, renaming the file doesn't work but Create/Delete will. That said, you need the running user password (that you have)
Compared to Weasly's suggestion, it just skips the export phase.
- create a second task using the first as template
- remove the original
dstname and an admin shell in Tasks folder:
C:\Windows\System32\Tasks>schtasks /Create /tn dstname /xml srcname /ru [running username] /rp [password] SUCCESS: The scheduled task "dstname" has successfully been created. C:\Windows\System32\Tasks>schtasks /delete /tn srcname /f SUCCESS: The scheduled task "srcname" was successfully deleted.
- With a little bit of scripting, you can rename a large bunch of tasks without effort
- If needed you should be able to extract the original RU from the XML (in node
- If you want schtasks to ask for the password, simply remove
Please be sure before you answer "Cannot do this", "Impossible", etc.
Check out this power shell script.
One possibility is, to export the task, delete the task, rename the file and import it again.
A good description can be found here: Rename task in task scheduler
You can't rename a scheduled task because that would change the
SID the task runs as.
The name forms the Security Identifier (SID) of the user the task will run as. Renaming the task would break any existing permissions.
There are a lot of people complaining about being unable to rename a scheduled task. There is a reason for it.
A scheduled task runs as some user, e.g.:
- some process account manually created in Active Directory (bad)
This means if your task needs to access some resources, you need to grant that user access to those resources.
What we really want it to grant access to that Task; that scheduled task itself should have the permissions - not the user the task runs as. This is called Task Security Hardening.
When a scheduled task is run, the task scheduler adds an additional Security Identifier (SID) in the token of the user running the task. E.g.:
NT TASK\[Task name](e.g. "NT TASK\The quick brown fox jumped over the lazy dog")
Group sid: S-1-5-87-x-x-x-x-x (e.g. S-1-5-87-2312335432-65297056-3549082870-2589977271-250352331)
The sid of this group is dynamically generated based on the hash of the name of the scheduled task. The group sid is a child of the authority
S-1-5-87. The SID's Relative ID
87 comes from the constant defined in
You can see this additional group SID in the security token of the launched process:
Generating Task SIDs
You can manually hash a task name, or see what the hypothetical sid for that task would be, by running a command-line tool:
>schtasks /showsid /TN "The quick brown fox jumped over the lazy dog" SUCCESS: The SID "S-1-5-87-2312335432-65297056-3549082870-2589977271-250352331" for the user name "The quick brown fox jumped over the lazy dog" has been computed successfully.
And you can use icacls to grant permissions to that group:
>icacls yellow.png /grant "*S-1-5-87-2312335432-65297056-3549082870-2589977271-250352331:(M)"
If the scheduled task is in a folder, you need to include that folder as well:
>schtasks /showsid /TN "Stackoverflow\Answer Question About Security" SUCCESS: The SID "S-1-5-87-1865438416-972601292-3915696002-2261943663-3756584440" for the user name "Stackoverflow-Answer Question About Security" has been computed successfully.
And, again, you can grant that SID permissions on the object:
>icacls yellow.png /grant "*S-1-5-87-1865438416-972601292-3915696002-2261943663-3756584440:(M)" processed file: yellow.png Successfully processed 1 files; Failed processing 0 files
And you can see the group having been granted permissions (in this case Modify permissions):
The good thing about:
- this virtual account system (which is also used by services with
NT SERVICEgroup, and by the IIS Application Identity)
- and with the special
is that these accounts have no password - no user is allowed to login as them. This means that you don't have to worry about the password leaking.
And on top of that, when you use
NT SERVICE, or
IIS APPPOOL virtual accounts to assign permissions: there is no way to impersonate that user. It's not a user in any sense. These are extra security boundaries that are a very good thing.
So of course you can't rename it
If you've been paying attention, you will now see why you cannot rename a scheduled task, or move it to another folder: it would change the hash of the task's name, changing the task's
NT TASK SID, and invalidate any permissions it's been granted.