There are files and directories in Windows OS such as Windows Vista, Windows 7, Windows 8, Windows 8.1, Windows 10 and so on that seem to impossible to delete and remove away. These persistent undeletable files and folders sometimes can’t even be accessed no matter what, even by an administrator, and you’re pretty sure that the files are not locked by running process. This situation always happen especially if you perform in-place upgrade from older version of Windows, such as from Windows XP to Windows Vista, from Windows Vista to Windows 7, from Windows 7 or Windows 8.1 to Windows 10, or install Windows on another partition or hard disk drive, leaving the old Windows used partition with its own data.

The problem symptom occurs because the undeletable files and folders’ ACLs (Access Control Lists) were set for accounts with SIDs that applied to an old partition. So these data will effectively owned by nobody or non-existent user when view in Vista operating system. In order to access the file for manipulation, modification or deletion, we will need to take control of the files under Windows.

We can use 2 command-line utilities to take ownership of the files or folders, and then grant full control access permissions to Administrators group, which supposedly you’re a member of. The 2 command line syntaxes are as below. Note that the full path should be included if you’re not at the current directory, and to run these commands, command prompt has to be in elevated mode.

For Files:

takeown /f file_name /d y
icacls file_name /grant administrators:F

For Directories (will perform action recursively):

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