Windows Vista Secret #11: Deleting the Undeletable

As many of us move forward from Windows XP or prior beta versions of Windows Vista to the final RTM version, I thought this little tip / secret might be in order. You may be aware that Windows Vista includes a number of different ways to upgrade a computer, from a straight in-place upgrade (insert CD, run setup and choose upgrade) to Windows Easy Transfer, which allows you to copy settings, programs and data from an old setup a fresh shiny new OS environment. But I'm the purist type who hates even the thought of leaving any detritus around and insists upon a clean install to a pure, unsullied partition.

In doing this, it's not unusual to find some folders that can't be accessed, even by an administrator, because their ACLs were set for accounts with SIDs that applied to an old partition. For example, on my home machine, I switched the C: and D: drive cables around and installed Windows Vista RTM on the new drive. Having tested everything worked, I wanted to delete some old redundant directories (like the old \Program Files directory). If even an administrator can't access the file, how do you take it back?

The secret lies in two command-line utilities, one ancient, the other completely revised for this release. Respectively, these are takeown (which takes ownership of a file or directory) and icacls (which sets new ACLs on that directory). I created a small batch command on my system called itsmine.cmd, as follows:

   takeown /f %1 /r /d y
   icacls %1 /grant administrators:F /t

From an elevated command prompt, you can run a command such as itsmine d:\hard_to_delete and this will reset ownership and ACLs on the hard_to_delete directory such that a command like rd /s d:\hard_to_delete should work.

These two lines have saved me a lot of pain over the last week as I've gradually flattened and reinstalled the RTM version of Windows Vista on each of my machines: hopefully they'll be equally useful to you!

Comments (19)

  1. Anonymous says:

    Tim Sneath provides two commands all IT persons should keep in their toolbox: takeown and icacls.

  2. Anonymous says:

    Thanks very much! That problem plagued me with a couple of folders

  3. Anonymous says:

    Awesome tip. Thanks Tim.

  4. Anonymous says:

    Well it has been a long, long, difficult project, but come tomorrow around 8:30 my time, all of my long

  5. Anonymous says:

    Hey, very nice!

    Is it perhaps possible to put this bath file in the Windows catalog and create a option "All your vase are belong to us" in the right-click drop-down menu using the same regedit actions as in WinXP?

  6. Anonymous says:

    I appreciate these tips, but when you click on the "secret" tag, the server only returns secret number 8 through 11.  Where are the rest of these "secrets"?  What is the point of numbering & tagging these posts if you don’t apply the tags in a uniform way?  :-]

  7. Anonymous says:

    Where are these commands located? I don’t see them on my system.


  8. Anonymous says:

    I ran into a situation where I needed access to my Program Files folder located in my first partition

  9. Anonymous says:

    Since when Micosoft decide what I can delete from my personal HDD and what not. Who do you think you are? Is my HDD and if I wand I can delete everythink! Why don’t you use yours brains and make different security options acording with everybody needs?

  10. Anonymous says:


  11. Anonymous says:

    By now I hope that most of you have atleast tried Vista. If not, join the bandwagon . INSTALL VISTA!!!

  12. Anonymous says:

    Thank yoiu very much for this solution. Prior to this, I had to rethink other solutions due to this barrier.

  13. Anonymous says:

    I just did a fresh install of Vista Ultimate on my home desktop PC. The install all went fairly smooth

  14. Anonymous says:

    I ran into a situation where I needed access to my Program Files folder located in my first partition

  15. Anonymous says:

    [Vista] Cancellare file lockati

  16. Anonymous says:

    Bonjour tout le monde !!! 🙂 Voila maintenant un long moment que je n’avais rien posté comme message ici 🙂 Et je fais mes plus plates excuses à ceux qui attendaient des nouvelles par le biais du BDM …

Skip to main content