Thursday, July 15, 2010

How to Take Ownership of a file in Windows 7

 

There are times when you cant do with a file what you want to do. For example you want to rename, remove, replace or relocated a file but Windows 7 doesn’t allow you to do that because it thinks that it’s a system file and you might end up corrupting it thereby un stabilizing your system. Now here is how you can do this.

Warning : Registry edition is a serious business which might go wrong. Its always advisable to backup your registry first and then do anything with it.

1. Open Notepad and copy-paste the following :

--------------------------------------------------------------------------------------

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"

 

-------------------------------------------------------------------------------------

save it as InstallTakeOwnership.reg file. When you double click on this you will see following standard warning message from microsoft

1

2. Click yes. It will give following message.

2

3. Its done. Now when you right click on any file you will see this entry

3

 

4. However if you find that it is making your system unstable or you encounter any problem, here is the solution to remove this registry entry.

Angel Open Notepad and copy-paste the following

----------------------------------------------------------------------------------------

Windows Registry Editor Version 5.00


[-HKEY_CLASSES_ROOT\*\shell\runas]

[-HKEY_CLASSES_ROOT\Directory\shell\runas]

----------------------------------------------------------------------------------------

5.  Save it is ‘RemoveTakeOwnership.reg’. Double click on it, say yes to the warning message and you are done.

No comments: