Skip to main content

Delete Windows Files with Permissions

Here is how to delete windows files that you cannot figure out the permissions.

For example files on a drive that contains an older windows installation, the users folder, the program data folder, the program files folder, the windows folder, the windows.old folder etc

The scripts bellow will create a context menu in your explorer. When you right click on a folder it will start taking ownership of the files, After this, you will be able to delete them!

You will need to import the following in to your registry :

 

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"

If you want to remove the right click menu use this :

Windows Registry Editor Version 5.00


[-HKEY_CLASSES_ROOT\*\shell\runas]

[-HKEY_CLASSES_ROOT\Directory\shell\runas]

Here is a zip file containing the reg keys that you can just import and you are done with out playing around with the code above : TakeOwnership

upggr

I am the one