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...
- from an administrator elevated command prompt
- 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...
- Sets the folder path
- Takes ownership of the folder and its contents recursively
- Grants
Everyone
ACLFull
level permissions to everything recursively- Forcefully and quietly deletes every file beneath the folder recursively
- 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.