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?


9 Answers 9

  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 and administrators 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.

  • 17
    For the Windows folder just rename it to Windows.old and with the disk cleanup tool/ program you can simply delete it
    – SuperDJ
    Commented May 25, 2018 at 10:50
  • 4
    Cacls is now deprecated, please use Icacls. Commented Feb 2, 2019 at 15:49
  • 2
    @Tharindu thanks, I updated the answer with icacls now. Please verify that it looks correct Commented Feb 22, 2019 at 13:47
  • 2
    rmdir is now rd
    – Penguin9
    Commented Nov 10, 2019 at 1:14
  • 1
    @RaisingAgent thanks for headups, I updated the code snippit with rd instead of rmdir Commented Nov 11, 2019 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
  • 1
    This worked for the "Windows" folder. Arne HD's 3 commands did work for some other folders such as "Program Files" and ProgramData.
    – Doochz
    Commented Jun 27, 2017 at 16:24
  • Smart! And Extremely simple. Worked like a charm.
    – oneavi
    Commented Jan 6, 2018 at 9:56
  • 9
    It works with any folder if you change the name to Windows.old. Awesome.
    – AdnanG
    Commented Nov 14, 2019 at 0:44
  • This is the best method, I tried 3 of the methods described here and this one was the best.
    – RaRdEvA
    Commented Nov 24, 2019 at 18:20
  • 1
    This works in December, 2020 for "Program Files", too. The command-based solutions didn't work for me. The name of the folder changed back automatically but this still set it as a target for disk cleanup. It didn't work for "Users", however. Commented Dec 9, 2020 at 20:39

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.)

  • That worked! Thanks!
    – JohnyL
    Commented Oct 26, 2020 at 19:23
  • 1
    This did not work for me, as during the second phase where you apply it to all child entries, I get an error that says it has no permission to iterate over the files.
    – Eduard G
    Commented Jul 21, 2023 at 17:24

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).


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.


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.

  • 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
    Commented Jan 19, 2016 at 4:02
  • 1
    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. Commented Jan 19, 2016 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
    Commented Jan 20, 2016 at 14:23
  • 2
    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 Commented Jan 20, 2016 at 14:31
  • 1
    Have no interest in discussing "EASIEST way to do it". Your statement is SHOUTING a completely false fact.
    – snayob
    Commented Jan 20, 2016 at 14:36

(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


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.


  • Uneducated guess. The NTFS file system uses user account SIDs in conjunction with access control lists, not the user account display names.
    – user477799
    Commented May 26, 2018 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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .