Can't delete folder and I am admin. "You need permission to perform this action. You require permission from..."
I am not sure why this happens but there is a workaround.
To take control of the folder containing the undeletable create a text file called “delete.bat” and add the following lines to it:
SET DIRECTORY_NAME="C:\Locked Directory"
TAKEOWN /f %DIRECTORY_NAME% /r /d y
ICACLS %DIRECTORY_NAME% /grant administrators:F /t
PAUSE
You will need to change the directory path to match your requirements e.g. “C:\Locked Directory” to “C:\Delete Me”.
Right click on the file “delete.bat” select “Run As Administrator” and you should now have full control of the directory and all sub directories meaning you can do what you wish with them.
The only way was to delete files starting from the lowest level folder in that folder. I got that error message with every folder which had subfolders. I deleted all files/subfolders working my way up.
A folder can disallow a parent from overwriting its permissions, so it stops working at a certain depth.
Use Process Monitor and filter for ACCESS DENIED events to figure out this depth
Every time an ACCESS DENIED event occurs change the permissions as explained by @Sahil.
You can use Handle too see what processes are opening files within your folder.
handle C:\Path\To\Folder\You\Are\Trying\To\Delete
Example:
C:\Windows\system32>handle C:\Windows\System32\inetsrv
Handle v3.45
Copyright (C) 1997-2011 Mark Russinovich
Sysinternals - www.sysinternals.com
svchost.exe pid: 1500 type: File 134: C:\Windows\System32\inetsrv\config\schema
svchost.exe pid: 1500 type: File 1B4: C:\Windows\System32\inetsrv\config\schema
svchost.exe pid: 1500 type: File 1BC: C:\Windows\System32\inetsrv\config
svchost.exe pid: 1500 type: File 1CC: C:\Windows\System32\inetsrv\config
svchost.exe pid: 1500 type: File 1D0: C:\Windows\System32\inetsrv\config
inetinfo.exe pid: 1572 type: File 3C: C:\Windows\System32\inetsrv\en-US\inetinfo.exe.mui
inetinfo.exe pid: 1572 type: File 188: C:\Windows\System32\inetsrv\MBSchema.bin.00000000h
inetinfo.exe pid: 1572 type: File 190: C:\Windows\System32\inetsrv\MBSchema.bin.00000000h
inetinfo.exe pid: 1572 type: File 1BC: C:\Windows\System32\inetsrv\MetaBase.xml
inetinfo.exe pid: 1572 type: File 1D4: C:\Windows\System32\inetsrv\MBSchema.xml
svchost.exe pid: 1884 type: File 1AC: C:\Windows\System32\inetsrv\config\schema
svchost.exe pid: 1884 type: File 1C0: C:\Windows\System32\inetsrv\config
svchost.exe pid: 1884 type: File 1C4: C:\Windows\System32\inetsrv\config