In Windows Vista, Windows 7 and Windows 8, almost all system files are under "TrustedInstaller" control. Its a system user account which has ownership of almost all system files.
If you are a Windows customization lover, you must be knowing that before replacing a system file to customize Windows look-n-feel, you first need to take ownership of the file. Ownership can be taken either manually or using a context menu option as mentioned in following articles:
- [Guide] How to Take Ownership (Permission) of a File or Folder Manually in Windows?
- How to Add "Take Ownership" Option in Files and Folders Context Menu in Windows?
But sometimes you might need to restore ownership of the file or folder to TrustedInstaller. We have posted a tutorial to restore ownership of files or folders to TrustedInstaller in past:
And now today in this article, we are going to make your life easier. Now you'll not need to manually restore ownership of a file or folder to TrustedInstaller because we are going to provide a ready-made registry script which will add a new option "Restore ownership" in files and folders context menu (right-click menu).

Once this option is added, you can simply right-click on a file or folder and select "Restore ownership" option and it'll restore "TrustedInstaller" as owner of that file or folder.
To add the option, download following ZIP file, extract it and run the extracted REG file. It'll ask for confirmation, accept it:
Download Registry Script to Add "Restore ownership" Option in Context Menu
An extra uninstallation registry script is also available in the above ZIP file in case you want to remove the option from context menu.
Thanks to our reader "PeaceSold13r" for sharing the command to restore ownership to TrustedInstaller which inspired us to create this automatic registry script...
Following video demonstrates this context menu option live in action:
Posted by: Vishal Gupta | Categories: Windows 7, Windows 8, Windows Vista
Josh S
Good idea, VG; thanks!!
In a related manner, is there a script we could use to remove all NTFS security info for a file?
SCBright
Good one!
I edited the reg file to match my own language ("Restaurar propriedade" instead of "Restore ownership").
Thanks VG!
actionOFdying
it's great ... thanks
Ashish
@VG
This script doesn't set back ownership of explorer.exe or explorerframe.dll. So what about those?
PeaceSold13r
Just tried it on 7 Ultimate x64.
Explorer.exe: shows a command prompt saying "access denied" but, in the end, it changes the owner.
Explorerframe.dll: no problems at all.
Sure that you're not confusing the owner with the security permissions? Because if you used the "take ownership" method, you will probably still be able to delete or modify the file.
mmn13
can you make it shown in drive context menu?
PeaceSold13r
[HKEY_CLASSES_ROOT\Drive\shell\restoreownership]
@="Restore ownership"
"HasLUAShield"=""
"NoWorkingDirectory"=""
[HKEY_CLASSES_ROOT\Drive\shell\restoreownership\command]
@="cmd.exe /c icacls \"%1\" /setowner \"NT Service\\TrustedInstaller\" /T /C"
"IsolatedCommand"="cmd.exe /c icacls \"%1\" /setowner \"NT Service\\TrustedInstaller\" /T /C"
Just add this lines to the .reg file. By the way it's not recommended to use this command for drives, because it will operate recursively and change the owner of all files and folders.
zydrius32
This doesn't work for me, “Add Take Ownership” too. There's a problem with CMD. It doesn't launch with administrator privileges e_e. I searched net a bit, and found working “Take Ownership”, look at code:
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\*\shell\runas]
@="Take Ownership"
"NoWorkingDirectory"=""
[HKEY_CLASSES_ROOT\*\shell\runas\command]
@="cmd.exe /c takeown /f \"%1\" && icacls \"%1\" /grant administrators:F"
"IsolatedCommand"="cmd.exe /c takeown /f \"%1\" && icacls \"%1\" /grant administrators:F"
[HKEY_CLASSES_ROOT\Directory\shell\runas]
@="Take Ownership"
"NoWorkingDirectory"=""
[HKEY_CLASSES_ROOT\Directory\shell\runas\command]
@="cmd.exe /c takeown /f \"%1\" /r /d y && icacls \"%1\" /grant administrators:F /t"
"IsolatedCommand"="cmd.exe /c takeown /f \"%1\" /r /d y && icacls \"%1\" /grant administrators:F /t"
UAC prompts me a message and I can press "Yes" to give access. Vishal, could you, please, look at code and recreate “Restore Ownership to TrustedInstaller”? Your created key only works in “Super Administrator” account. I don't want to turn off UAC.
VG
^^ I found that these registry scripts have problems in Windows 8. These scripts work fine in previous Windows versions. I have modified both take and restore ownership registry scripts to work in Windows 8 as well. Please re-download and check them again. :)
zydrius32
Thank you! I'm using not “Windows 8”, but this worked for me.
Thanh
Hello! I've tried all your two scripts "Take Ownerships" and "Restore Ownerships" on Windows 8. But there has a problem: All your scripts make key "HKEY_CLASSES_ROOT\*\shell\runas" for Take and Restore, so that I can not add all of these 2 scripts at a same time. I've tried make "HKEY_CLASSES_ROOT\*\shell\TakeOwner" and "HKEY_CLASSES_ROOT\*\shell\Restore" for each scripts, but after that they didn't work. Can you help me to fix this? Thanks!
VG
^^ It was done intentionally to make things working in Windows 8.
Frank F.
You are saying then that this tweak does NOT work in Windows 8?
Am confused, as headline at the top says "...in Windows Vista, 7 and 8." (note the 8)
Would really like to get this working, as there are hundreds of useless files that, if deleted, would free up much space on the tiny SSD drive here.
Frank F.
by the way, believe you are really swell for paying such prompt attention to the little concerns of you readers.
Frank F.
Oh wait a second, am in the wrong place. The tweak that won't work for me is the "Restore Ownership" one. Will try to find it....?