11

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?

10 Answers 10

32
  1. Open a Command Prompt with administrative privileges.
  2. Run the following commands line by line, but in doing so, change "Z:\Program Files" to whatever you actually want to delete.

    takeown /F "Z:\Program Files" /A /R /D Y
    icacls "Z:\Program Files" /T /grant administrators:F
    rmdir /s /q "Z:\Program Files"
    
  • 3
    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
  • 1
    Cacls is now deprecated, please use Icacls. – Tharindu Sathischandra Feb 2 at 15:49
  • 1
    @Tharindu thanks, I updated the answer with icacls now. Please verify that it looks correct – Arne H. Bitubekk Feb 22 at 13:47
14

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
  • 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
2

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

0

(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

0

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.

0

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

-1

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.

-1

https://www.youtube.com/watch?v=MB1vbD3SNdY

One click solution please watch this : https://www.sevenforums.com/tutorials/1911-take-ownership-shortcut.html

We may have replaced smaller hard drives with bigger ones and installed Windows on them. If we want the data on the old drives but don’t want to format them to get rid of all the Windows and Program Files folders, normally, we can’t delete these folders due to permission. There is a very easy way to do it, all we need is the Add_Take_Ownership.reg added to the registry of the Windows we’re running. We can download the file here.

Extract and double click the Add_Take_Ownership.reg to install. When it’s done, right click the OLD Windows folder and select “Take Ownership” to change permission (MAKE SURE IT’S NOT THE ACTIVE WINDOWS FOLDER YOU’RE RUNNING). When it’s done, just delete the OLD Windows Folder.

Folder Access Denied takeownership

Add_Take_Ownership.reg Installation Add_Take_Ownership.reg Installation

Change Permission On Folder Change permission on folder

-2

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 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
-2

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.

Cheers

  • 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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