Two Files Will Not Delete From HDD

Solution 1:

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

  • takeown
  • icacls
  • del
  • rd

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.