Windows – Two Files Will Not Delete From HDD

permissionswindows 7

I'm prepping to upgrade to Windows 10, finally, and I'm running into some trouble while clearing out my storage HDD. There were two files on there, an EXE and an OCX file relating to Adobe Flash 10. They are being very stubborn about being deleted, here is what I've tried:

  • Shift+Del: claims the files are in use by something
  • When deleting them normally, I see "You require permission from PCNAME\MY USERNAME to make changes to this folder"
  • I am the owner of these files and the parent folder, and I have granted myself full permissions for the folder and children items
  • Right Click > Take Ownership: no luck after doing this, although the process is successful
  • I can rename these files and Cut-Paste them to wherever I please, but I cannot delete them.
  • Powershell: Tried Remove-Item '.\Delete Me' -Force -Recurse but error claims 'Access to the path is denied.'
  • Powershell: rm '.\Delete Me' -Force returns the same error
  • PsExec: Tried running Powershell as SYSTEM, no dice, same errors as above
  • Third party software Unlocker: claims the files become unlocked and process-free, but they still can't be deleted
  • Another answer on StackExchange had me try a .bat file to take control, but no dice
  • They are marked as Read-Only files, but I do not have permission to change that
  • Safe Mode: no go. Same errors as before.

To be fair, the files only amount to 4MB of space, but it's principle at this point; I don't want to be defeated by two measly files. Formatting the disk seems a bit of a Genos thing to do (think: overkill). So, what else can I possibly do to get rid of them?

Best Answer

To forcefully delete a folder that just won't delete no matter what

Run the below commands...

  1. from an administrator elevated command prompt
  2. or save as a batch script and set it to run as a startup script using Group Policy or Task Scheduler if #1 doesn't resolve on its own.

The Commands

These commands essentially...

  1. Sets the folder path
  2. Takes ownership of the folder and its contents recursively
  3. Grants Everyone ACL Full level permissions to everything recursively
  4. Forcefully and quietly deletes every file beneath the folder recursively
  5. Removes the directory itself once all the above complete in that order

Commands and Batch Script

SET "Folder=C:\Delete Me"
takeown /a /r /d Y /f "%Folder%"
icacls "%Folder%" /grant everyone:F /t
DEL /Q /F /S "%Folder%\*"
RD /S /Q "%Folder%"

Supporting Resources


Further Notable Items

Other reasons why folders cannot be removed are...

  • Hidden files or something within the folders that has something "in use" so it cannot be removed until that process is stopped/killed

    • Start killing processes from memory, stopping services, disabling task scheduler jobs, etc. to stop a process from using a hidden file within the folder which you cannot see
  • File replication services or technologies attached to these folders within the file system such as DFS, mount points, etc.

    • Stop the replication of whatever replication technology is being used on the file system
  • File system level corruption

    • run chkdsk C: /F /R /X

If nothing is working to resolve still, I suggest you perform a full anti-malware scan as well as an offline full AV scan with fully updated definitions that detect malicious bugs and so forth.