Take ownership of a file in Windows

Have you ever had an issue deleting or otherwise owning a file in Windows? Well, I have.

Here are some ideas on how to own a file.  Take each step by step.  If #1 doesn’t work, move on to #2.

  1. Try to delete the file in windows explorer. Of course, this is the “easy” way. No can do? How about…
  2. Try to change permissions on the file first, using the right click/properties/security tab.
  3. Still no love? How about trying to delete this file from the command prompt.
  4. Next, try deleting the file from the command prompt that is running as administrator (start-cmd then right click, run as administrator)
  5. Will safe mode work out? Try to reboot into safe mode. This will remove all file handles that are attached to the file, any programs that are using the file will be closed. This will work if the file is opened for use by another user or program.
  6. Finally, this should absolutely work.
    * Boot into safe mode (which removes the dependency of other programs using the file)
    * Log in as Administrator
    * Open a command prompt
    For files:
    C:\> takeown /f file_name /d yicacls file_name /grant administrators:F
    For directories and recursively, all nested files/directories:
    C:\> takeown /f directory_name /r /d y
    C:\> icacls directory_name /grant administrators:F /t


<Originally posted 25/October/2011 on blogspot>
( External reference: http://www.mydigitallife.info/delete-undeletable-files-in-windows-vista/comment-page-1/#comment-938578 )