Address: http://blogs.msdn.com/tims/archive/2006/11/10/windows-vista-secret-11-deleting-the-undeletable.aspx
By Tim Sneath
Translation: Tony Qu (from the BluePrint Translation Team)
Most of us are switching from early Windows XP or Windows Vista to final RTM. I think this tip is suitable for us. You know that Windows Vista has many different ways to upgrade your computer, from directly replacing the installation (insert CD, run the installation, and select the upgrade) to Windows Easy Transfer (allows you to copy settings, programs, and data from an old installation to a new system environment ). However, I am a purification commentator who does not want to have any fragments and insists on installing the system to a pure partition without any stains.
During installation, even the administrator can find folders that cannot be accessed, because the account ACL settings are completed by the SID originally applied to the old partition. For example, on my home machine, I changed the C: And D: Drive lines and installed Windows Vista RTM to a new drive letter. When I test and confirm that everything works well, I want to delete some old redundant directories (such as the old program files directory ). If the administrator cannot access these files, how can you obtain the permissions?
The secret is hidden in two command line tools, one of which is relatively old and the other is completely revised for this version. They are takeown (you can get a file or directory ownership) and icacls (you can set a new ACL for a directory ). I created a batch processing program named itsmine. cmd on my system, as shown below:
Takeown/f % 1/r/d y
Icacls % 1/grant administrators: F/t
In an upgraded (elevated) command prompt, you can run a command, such as itsmine d: \ hard_to_delete, which resets the ACL with the permission and the hard_to_delete directory, for example, rd/s d: \ hard_to_delete should be run.
Last week, these two lines of commands have reduced my pain because I am getting familiar with them and re-installed Windows Vista RTM on each calculator: I hope they will also work for you.