Are you trying to delete a users profile directory or an old Windows folder and it is a pain to remove? Or do you have spyware that installed itself and you are have a tedious process of deleting these files from the GUI? I have put together the commands I use to delete those pesky undeletable files. I am not talking about locked files but the ones where you have to take ownership and then give yourself rights to even when running as administrator.

Warning!!! Only do this if you know what you are doing – you can cause problems on your machine if you don’t know what your doing.

First start an elevated prompt: Click <Start>; type CMD; right click CMD program; choose “Run as administrator”. Now change to the directory you want to work in and then:

Command What does it do?
takeown /f *.* /r /d y Takes ownership of all files and folders from the current directory on down.
icacls *.* /grant administrators:F /t Assigns full rights to the administrators group of all items in the current folder
del *.* /f /q Deletes all files in the current folder.
-The F means: Delete File even IF it’s Read Only.
-The Q means: Quiet: you don’t have to Confirm.
rd /s /q <directory name> This will delete that folder and all files and folders within. Replace <directory name> with the name of the directory you want to remove.
– The RD – stands for remove directory.
– The S means: include all subdirectory tree
– The Q means: Quiet: you don’t have to Confirm.