How to change a registry key owned by TrustedInstaller from the command line

Issue

When trying to change a registry value that the registry key is owned by TrustedInstaller, the command fails, even when run from an administrative command prompt.

e.g. Hiding Network in Explorer
C:\>REG ADD "HKLM\SOFTWARE\Classes\CLSID\{F02C1A0D-BE21-4350-88B0-7367FC96EF3C}\ShellFolder" /v Attributes /d 0xb0940064 /t REG_DWORD /f
ERROR: Access is denied.

Resolution

SetACL can be used to take ownership, and to grant permissions. Ensure the following commands are run from a "Run as Administrator" command prompt.

Take Ownership
C:\>SetACL.exe -on "HKLM\SOFTWARE\Classes\CLSID\{F02C1A0D-BE21-4350-88B0-7367FC96EF3C}\ShellFolder" -ot reg -actn setowner -ownr "n:Administrators"
INFO: Processing ACL of: <machine\SOFTWARE\Classes\CLSID\{F02C1A0D-BE21-4350-88B0-7367FC96EF3C}\ShellFolder>

SetACL finished successfully.

Grant Permissions
C:\>SetACL.exe -on "HKLM\SOFTWARE\Classes\CLSID\{F02C1A0D-BE21-4350-88B0-7367FC96EF3C}\ShellFolder" -ot reg -actn ace -ace "n:Administrators;p:full"
INFO: Processing ACL of: <machine\SOFTWARE\Classes\CLSID\{F02C1A0D-BE21-4350-88B0-7367FC96EF3C}\ShellFolder>

SetACL finished successfully.


The command will now complete successfully:
C:\>REG ADD "HKLM\SOFTWARE\Classes\CLSID\{F02C1A0D-BE21-4350-88B0-7367FC96EF3C}\ShellFolder" /v Attributes /d 0xb0940064 /t REG_DWORD /f
The operation completed successfully.


References

Products

Microsoft Windows Server 2008 R2 RTM
Microsoft Windows Server 2008 x64
Microsoft Windows Server 2008 (any)
Microsoft Windows 7 x64 RTM
Microsoft Windows 7 RTM

Created: 28th October 2010
Updated: 28th October 2010


© 2005-2014 Jamie Morrison