I recently installed a new faster hard drive on my computer, and I am using the old drive as a secondary. I am running Windows 7 Professional, and it won't let me delete the Windows directory off of the old secondary drive. I even tried using RMDIR /s E:\Windows from an elevated command prompt. Same problem: access denied. Surely I'm not the first person to try this. How do I fix it?

  • 1
    Just download a Linux Live CD and delete it.
    – cutrightjm
    May 24, 2012 at 0:16
  • 1
    Have you tried taking ownership of the folder and removing the System attribute?
    – user3463
    May 24, 2012 at 0:25
  • @RandolphWest: How would I do that?
    – Jim Fell
    May 24, 2012 at 0:28
  • takeown /F D:\Windows /R /A /D N and then attrib D:\Windows\*.* -S /s
    – user3463
    May 24, 2012 at 3:18
  • 2
    @JimFell Incase iti s a changing ownership thing, I see you ask how to do that. Come on jimbo, google for changing ownership of a file/folder. You'll find loads of links. Infact if you just googled the error message you'd probably see tons of links about it. I know when i've had an error removing a folder i've googled it and seen about changing ownership
    – barlop
    May 24, 2012 at 3:19

8 Answers 8


At least following worked for me:

takeown /f x:\windows /r

added full rights to the folder in properties -> security

icacls x:\windows /reset /T

Download and burn an Ubuntu LiveCD http://www.ubuntu.com/

Then boot into that LiveCD (usually place the CD in the drive, restart your computer while holding down F12 )

The Ubuntu Distribution will take a little while to load, once it does it should recognize your internal hardrives. You can find more info here: http://www.psychocats.net/ubuntu/mountwindows

Just remove these folders through Linux.

rm -rf <path to directory to remove>

if this fails because of privileges try

sudo rm -rf <path to directory to remove>

Be warned, you should be absolutely sure you do not need these directories.


Windows 10 how to steal a full ownership of protected folder I just deleted Windows,Program Files, Program Files(x86) folders from the old hdd disk.

  • Select a folder in a file explorer
  • 2nd mouse button/Properties/Security tab
  • Advanced button, Click on the Owner: xxx (Change) hyperlink
  • Type in the your username or use Advanced to search for user object.
  • Click [x]Replace owner on subcontainers.. field
  • Click on the Apply button
  • Click on OK to close all permission windows

  • 2nd mouse button/Properties/Security tab, second time

  • Advanced button
  • Click on the Add or select your own username row in a listbox.
  • Apply [x]Full control and everything else to your username object, if doubt apply a generic all users group to have a full control as well.
  • Click [x]Replace all child object permission entries.. field
  • Click on the Apply button
  • Click on OK to close all permission windows

Delete a windows, program files or any protected folder you took.

  • 2
    I can confirm that this works. I have an old hard drive that I plugged in to my laptop in an enclosure and had this problem, and this was the only list of instructions I've been able to find that lets me delete it. May 20, 2017 at 18:46
  • for some reason it complains that it needs permission from my account which i am logged into but i cant grant :/ actually messing around with trustedInstaller since i´m a kid
    – john Smith
    Sep 29, 2021 at 6:59

You must take ownership and then grant yourself Full Control permissions to the folder.

Taking ownership only gives you the ability to change ACLs. Granting yourself permissions then gives you the ability to delete the files/folders.


I ended up reformatting the drive from an elevated command prompt, which effectively wiped out everything on the drive, including the Windows directory.


I installed a new solid state drive (SSD) pre-loaded with Win 7 Home Edition OS and my program files in the primary bay of my laptop . I plan to use the original HDD in the second bay of my laptop for data files. I had to clean out all the OS-related files and folders from this HDD and leave my existing data files intact.

I installed the HDD in the second bay of my laptop (it could be left outside and connected via a USB port) and tried to delete the OS files with Windows Explorer. The running Windows OS would not let me delete the system files. I tried several ways of changing permissions and none of them worked for me. So, I used a program called "PartedMagic",. The PM program gets loaded via a CD on power-up, before Windows boots, so Windows cannot invoke it's rules against deleting System Files.

Here's the short procedure: Download the PM program, save it, and burn it to a CD. Insert the CD and reboot the computer. Set the BIOS to boot from the CD. Among many other things, PM has a "Windows Explorer" like feature. Open it, navigate to the correct HDD and delete all the files and folders related to the OS. While you are there, delete any other unwanted folders and files. Defrag the HDD and your done.

Details left out of the short procedure:

Insert the CD created above into the CD tray and close it. Restart the pc. When the pc starts to boot up, press the ESC key (or f10 key) repeatedly to enter the BIOS. Set the BIOS to boot from the CD. Select "1", the default setting, on PM. After the program has loaded, click on the "Explorer" icon. Select the HDD you want to work on and start deleting. When you think you have removed all of the "undeletable" files and folders you "might" be done. Restart your computer. It should boot to the installed OS. If not, remove the CD and try again. Take a look at the HDD contents with Windows Explorer. You can delete unwanted non-OS data with WE.


I used another neat program that runs in Windows called WinDirStat to do a final clean up. Download and run the program. Select the drive you are working on. This program presents a great visual display of the HDD contents. Note: be patient, it takes WinDirStat a few minutes to crunch the contents and display it. Navigate around the colorful display and, when you are done deleting, run a defrag program. You are set go with lot's of space to store your data.

P.S. Please don't interpret anything in this procedure as disparaging toward Microsoft products. I like Windows 7.


Change the ownership of windows folder,

Right click on windows folder, security tab, advanced button , change principal , type your user name, then ok,, add ur user name again on secuirity , then go back to advanced button, enable inherit, and check small box below inherit then ok,, u will able to delete that folder now


As I recall you can do that using a boot disk

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