Monday, 2 December 2013

Windows: Cannot open folder Access Denied

Cannot open folder Access Denied

Have you ever given your flash disk to someone and when you get it back, you cannot access files or folders again?

If yes there is a simple solution:
You need a registry key called TakeOwnership, what this does it when you right click on the folder there is a menu item that allows you to take ownership of the file/folder.

The registry Key looks like this:
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"

#bearMan, Saving you time in windows.