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 usingschtasks.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.
Using
srcname
anddstname
and an admin shell in Tasks folder:Notes:
Task/Principals/Principal/UserId
)/rp [password]
portionUnfortunately not. That's the way this is done now. I believe it's for security purposes, so that set tasks cannot be modified while they are actually setup and enabled.
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
Short Version
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.
Long Version
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.:
Local Service
(good)Network Service
(good)System
(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.
Task 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.:
Name:
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 ID87
comes from the constant defined inwinnt.h
: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:
And you can use icacls to grant permissions to that group:
If the scheduled task is in a folder, you need to include that folder as well:
And, again, you can grant that SID permissions on the object:
And you can see the group having been granted permissions (in this case Modify permissions):
The good thing about:
NT SERVICE
group, and by the IIS Application Identity)Local Service
andNetwork Service
accountsis 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 TASK
,NT SERVICE
, orIIS 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.Yes it's possible ! Just export the task (right click on the task / Export...) as an XML file (on the Desktop for instance). Then, delete the task in the Tasks Scheduler and right click / Import a task. Choose the previously saved XML file, rename the task and save it. Voila.