My PC has a bunch of extra drives. Most of them contain old copies of Windows and Program Files. My PC is called "PC", and my admin user is called "Tim". I've assigned ownership of these second drives to the user "PC\Tim", and also given the user "PC\Tim" full control on the drives. I then try to delete either the Windows or Program Files folders on these drives, and get the message.

"You require permission from PC\Tim to make changes to this folder."

The current owner of these folders is listed as "Tim (PC\Tim)". The effective permissions for these folders lists this user has every right.

The absurd "answers" on the microsoft community of course offer things like "Use Disk Cleanup" (which is a blatantly uneducated answer) or "just reformat the drive" (formatting avoids the problem rather than addressing it).

What are the correct steps to delete these old files?

  1. Open a Command Prompt with administrative privileges.
  2. Run following commands, one at a time (change "Z:\Program Files" with folder you want to delete):

    takeown /F "Z:\Program Files" /A /R /D Y
    icacls "Z:\Program Files" /T /grant administrators:F
    rd /s /q "Z:\Program Files"

Note 1 - OS Language: takeown ... /D Y The input Y stands for 'Yes' and will be different depending on OS Language. Program Files folder may also be named differently.

Note 2 - Older versions of Windows: If icacls and rd are not supported then try use cacls and rmdir instead

Explanation and documentation:

The issue might be that you do not have the correct permissions in the discretionary access control lists (DACLs) for the folder and its content. DACLs identifies the trustees that are allowed or denied access to a securable object. So simply giving the ownership to the folder might not be enough, but you also needs to grant permission in the DACLs. You can grant permission using the icacls command as shown as example above. Access Control Lists and DACLs explained

takeown takeown documentation Administrator recovers access to a directories and it's content that previously was denied, by making the administrators group the owner. /F [directory] specifies which directory, /A gives ownership to administrators group, /R performs it as recursive operation on directory, all files and sub-directories, /D suppresses confirmation prompts when user does not have "List Folder" permission with following Y option which take ownership of the directory. (Note: The Y option may be different depending on OS language).

icacls icacls documentation Grants the administrators group full access DAC permissions to directory. [directory] specify which directory, /T performs the operation on all specified files in directory and sub-directories, /grant grants specified user access rights with :F which gives full access. (Note: The group name administrators may be different depending on OS language)

rd rd documentation Deletes the directory with all its sub-directories and files. /s deletes the specified directory and its sub-directories including all files, /q specifies quiet mode so you get no prompt for confirmation, [directory] specify which directory to delete.

| improve this answer | |
  • 11
    For the Windows folder just rename it to Windows.old and with the disk cleanup tool/ program you can simply delete it – SuperDJ May 25 '18 at 10:50
  • 2
    Cacls is now deprecated, please use Icacls. – Tharindu Sathischandra Feb 2 '19 at 15:49
  • 1
    @Tharindu thanks, I updated the answer with icacls now. Please verify that it looks correct – Arne H. Bitubekk Feb 22 '19 at 13:47
  • 1
    rmdir is now rd – Penguin9 Nov 10 '19 at 1:14
  • @RaisingAgent thanks for headups, I updated the code snippit with rd instead of rmdir – Arne H. Bitubekk Nov 11 '19 at 8:19

What worked for me was a simplified version of this suggestion:

  1. Rename the Windows folder to Windows.old
  2. Run Disk Cleanup from the Start menu
  3. Select the drive containing the Windows.old folder
  4. Previous "Windows Installation(s)" then click on OK
| improve this answer | |
  • 1
    This worked for the "Windows" folder. Arne HD's 3 commands did work for some other folders such as "Program Files" and ProgramData. – gus Jun 27 '17 at 16:24
  • Smart! And Extremely simple. Worked like a charm. – oneavi Jan 6 '18 at 9:56
  • 3
    It works with any folder if you change the name to Windows.old. Awesome. – AdnanG Nov 14 '19 at 0:44
  • This is the best method, I tried 3 of the methods described here and this one was the best. – RaRdEvA Nov 24 '19 at 18:20
  • This is brilliant! I can't believe this works! The cmdline stuff worked for the other folders, but this finally worked! – MDT Guy 11 hours ago

This worked in Windows 10 SPANISH:

set del_folder=F:\Program Files
takeown /f "%del_folder%" /r /d S
icacls "%del_folder%" /grant administradores:F /T
rmdir /s /q "%del_folder%"

In the takeown command, you have to use an "S" at the end for "Sí" in Spanish, instead of "Y" for "Yes" (English).

For the icacls command, you need to use "administradores" (Spanish) and not "administrators" (English).

| improve this answer | |

NOTE: Now that I think about it, you should be able to start from step 4, you just need to hit the "change permissions" button to get access. I'd test, but I'm out of directories to delete.

On Windows 10 (probably works with Windows 7 and 8 as well):

  1. Right-click on folder->properties->security->advanced.
  2. Click on Change next to owner (at the top). Enter your user name in the box, and hit check names. (Should convert into a MACHINENAME\USERNAME style.)
  3. Hit OK, OK, OK to get out of the security options.

You should now own the directory.

  1. Right-click on folder->properties->security->advanced. (Again.)
  2. Find "Users" in the permissions list. Click it, select edit, and choose full control.
  3. At the bottom, check "Replace all child permission entries...".
  4. Hit OK, then choose Yes in the warning box. Wait for the computer to apply the new permissions.

You should now have the permissions needed to delete the files. Do so. (Tested on both Program Files folders and Windows.old.)

| improve this answer | |
  • Tested, it works! thanks! – GoTo Sep 5 '19 at 22:32
  • That worked! Thanks! – JohnyL Oct 26 at 19:23

Simple rename Program Files to Windows.old and run disk clean to clear system files. Same trick work on any folder what you cannot remove.

| improve this answer | |

(For windows folder) If you can,change the name to windows.old.Then open disk cleanup,select the drive and click ok.After that click 'clean up system files' and it will delete the folder

Now if you can't rename the folder,download unlocker,open it and select the folder then click rename and change the name to Windows.old and then run disk cleanup. :D

| improve this answer | |

Create a live USB of your Linux distribution of choice, boot into that, mount the drives, and clean them up that way. Literally the easiest way to do it.

| improve this answer | |
  • 1
    I think the question is more about file permissions/ownership than just deletion of files. If there is a possibility to achieve task using Windows tools why should anybody download say 500MB and more and create a bootable USB? I am also not 100% sure that every Linux distribution "of choice" can handle correctly all versions of NTFS. NTFS is not a Linux file system. Would you use Windows to manipulate files on Linux ext4 file system? – snayob Jan 19 '16 at 4:02
  • The Linux kernel can handle over 50 file systems. Also, it is literally the EASIEST way to do it. Maybe not what this user was looking for, but it is easy. – Steven Perszyk Jan 19 '16 at 23:51
  • 1
    Easiest? Downloading 1GB and burning to USB? Is this really easier than issuing 3 commands? You seem to be a real Linux guru ;) – snayob Jan 20 '16 at 14:23
  • 1
    I'm not quite sure how that random and completely false "fact" pertains to the discussion on hand but thank you for enlightening me. If you want to have a personal discussion on why one would choose a GNU/Linux system, I'd be happy to have that discussion somewhere else. Other than that this discussion is getting terribly off topic – Steven Perszyk Jan 20 '16 at 14:31
  • 1
    Have no interest in discussing "EASIEST way to do it". Your statement is SHOUTING a completely false fact. – snayob Jan 20 '16 at 14:36

It could be possible that you already have ownership of the same user, due to it being a previous disk that was hosting your system. Remove that ownership and add it again (the same one). For example, if user PETER has ownership, remove it, apply to all subfolders, then add PETER again, and apply. You should be then able to first rename the folder you wish to delete, and then delete it.


| improve this answer | |
  • Uneducated guess. The NTFS file system uses user account SIDs in conjunction with access control lists, not the user account display names. – user477799 May 26 '18 at 21:32

Assuming that the deletion has to be made on a second drive: What has just worked for me is:

  1. install Lockhunter (free application to unlock and rename locked files) run Lockhunter with Admin privileges;

  2. rename the folder to delete to "Windows.old" (you will still read the original name after the renaming but don't worry the renaming will be confirmed by Lockhunter in it main window);

  3. run "Disk Cleanup" with administrative privileges;

  4. select the folder to delete that will appear with the name "Windows.old" in Disk Cleanup and delete it.

| improve this answer | |

Not the answer you're looking for? Browse other questions tagged or ask your own question.