Deleting Files with Broken Windows File Permissions

I’ve encountered this issue several times on windows VMs (sadly need a few still) where modern versions of Windows, i.e. Windows 8 will occasionally prevent you from deleting a directory. One was a directory an installer created, in this case Open Office, which was not cleaned up due to a VM crash during the install process. The file was showing ownership set to my regular user account. However the user could not delete the file, Windows would simply say I have to get permission from myself to delete it. I tried logging in as Administrator and assigning ownership to Administrator via the Advanced menu in the Security tab of the file properties. At this point windows would still tell me I need the non-Admin user’s permission to delete it (wtf, I’m admin…) and would now tell the regular user I need Admin’s permission to delete it. Basically windows has become the operating system equivalent of the DMV or any other government operation with an added touch of dementia.

I found the following commands as Administrator from command prompt solved my issue:

takeown /f "C:\Users\myusername_000\Desktop\OpenOffice 4.1.1 (en-US) Installation Files" /r /d y
icacls "C:\Users\myusername_000\Desktop\OpenOffice 4.1.1 (en-US) Installation Files" /grant administrators:F /t

After that I was able to right click and delete the directory without issue as Administrator. Overall it’s pretty crappy that windows can’t work out file ownership/permissions. This is something that has worked on Unix and Linux, without issue, since as long as most of us can remember.

Add a Comment