Experimenting with C:\Windows\System32\CompatTelRunner.exe
1. Change the ownership to Administrators
Hit WinKey+r, type cmd, hold down
Ctrl+Shift and press Enter.
1
Then run :
2
dir /q CompatTelRunner.exe
Expect the response to contain a line like :
<Date> <Time> <bytes> NT SERVICE\TrustedInstaCompatTelRunner.exe
(Unfortunately, NT SERVICE\TrustedInstaller gets cut off.)
This response shows that the current owner is TrustedInstaller.
Next run :
3
takeown /f CompatTelRunner.exe /a (1)
Now expect the response from dir /q CompatTelRunner.exe to be :
<Date> <Time> <bytes> BUILTIN\Administrators CompatTelRunner.exe
showing that the owner has been changed to Administrators.
2. Extend the access permissions of the Administrators
Run :
4
icacls CompatTelRunner.exe
Expect the response to contain the following two lines :
NT SERVICE\TrustedInstaller:(F)
BUILTIN\Administrators:(RX)
This response shows that the TrustedInstaller still has Full control
(even though it's no longer the owner), while the Administrators
group still has only Read & eXecute permissions (even though it's now
the owner).
Then run :
icacls CompatTelRunner.exe /grant Administrators:f (2)
Now expect the response of icacls CompatTelRunner.exe to contain the
lines :
BUILTIN\Administrators:(F)
NT SERVICE\TrustedInstaller:(F)
showing that the Administrators group now also has Full control.
3. Set the ownership back to TrustedInstaller
Run :
icacls CompatTelRunner.exe /setowner "NT SERVICE\TrustedInstaller" (3)
Expect the response from dir /q CompatTelRunner.exe once again to be
:
<Date> <Time> <bytes> NT SERVICE\TrustedInstaCompatTelRunner.exe
showing that the owner has now been restored to TrustedInstaller.
4. Reset the access permissions of the Administrators
The only thing that remains to be restored is to set the permissions
of the Administrators group back to just Read & eXecute :
icacls CompatTelRunner.exe /grant:r Administrators:rx (4)
Expect the response of icacls CompatTelRunner.exe now to contain the
lines :
BUILTIN\Administrators:(RX)
NT SERVICE\TrustedInstaller:(F)
showing that the access permissions of the Administrators group has
been restored.
5. Why you got Access is denied
Is it clear by now why you got Access is denied?
– The reason is that when you took ownership of the file,
you still did not have full access permissions on it.
So when you tried to set the ownership back to TrustedInstaller, you
didn't have the necessary permissions to do so, and hence got
Access is denied.
Taking ownership of the file is the correct first step, because
otherwise you are not allowed to extend your permissions.
6. What's the point?
Running the above commands (1), (2), (3), (4) – in that order – will
restore your operating system to how Microsoft sets it up.
This is true regardless of whether the access permissions of this file
were already restored or not.
So what's the point?
– Well, I never used to run the commands (3) and (4).
And I don't intend to do so in the future either.
Why should I?
– As long as I trust my administrators (including myself), I
don't really see any reason to restore things to being
the Microsoft way.
Answering this question has still been worthwhile as I have learned to
take ownership and change access permissions of a file.
And to understand the difference between the two.
References
1 Holding down Ctrl+Shift makes the
command prompt open as administrator.
2 The command dir /q <SomeFileName> displays the owner of
the file <SomeFileName>.
3 The flag /f is needed to indicate that what follows
next is the name of the file/folder.
The flag /a gives ownership to the Administrators.
4 ICACLS stands for Integrity Change Access Control ListS.