Deleting locked folders on a Windows 7 external USB drive

I noticed that a 250GB USB external drive I used for various storage tasks had a number of locked folders, with what looked like arbitrary Windows-generated folder names. The contents of the folders looked like temporary installation setups, so I tried to delete one of them. I was told "Folder Access Denied"; I had insufficient permissions to delete the folder. To obtain sufficient permissions is a bit convoluted, but I least I could then delete these useless folders.

Here's what you need to do:

  1. Right-click on an offending folder and choose "Properties".
  2. Click on the "Security" tab.
  3. Click on the "Advanced" button.
  4. Click on the "Owner" tab.
  5. Click on the "Edit" button.
  6. Change the owner to you, by selecting your id from the "Change owner to:" list. If you are not on the list, you've got a problem!
  7. Tick the "Replace owner on subcontainers and objects" box.
  8. Click "Yes" on the confirmation dialog.
  9. Click "OK" on the information dialog.
  10. Click "OK on all subsequent dialogs until they all are closed.

You should now be able to delete the folder.

It is also possible to achieve this end by using the subinacl command at the cmd.exe command line. It is not installed by default, you have to download it from Microsoft. You can run it like so:

  subinacl /subdirectories "folder" /setowner="domain\newowner" /grant="domain\newowner"=F
  subinacl /subdirectories "folder\*.*" /setowner="domain\newowner" /grant="domain\newowner"=F

You seem to have to change the containing folder first, and then all its children.