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?


3 Answers 3


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 Microsoft Defender Offline scan with fully updated definitions that detect malicious bugs and so forth.

  • 1
    Really thorough answer too, well done. Thanks again! Jul 21, 2019 at 18:35
  • Why grant Everyone full access? Would it work if you grant it only to yourself/Administrators?
    – Oskar Skog
    Nov 11, 2023 at 23:57
  • @OskarSkog Since you're removing it, the primary objective will eliminate the ACL security anyway, with no specific concern other than ensuring that all possible security principals have access before deletion. Although the outcome may or may not align with the other security configuration you inquired about, my typical approach is to follow this procedure, and it usually proves effective. Nov 12, 2023 at 1:27

Try deleting the files on the administrator account.

Enable it by doing this:

Hold the Windows Key while pressing “R” to bring up the Windows Run dialog box. Type: net user administrator /active:yes Press “Enter“.

(if you want to disable the administrator account just run that again but replace yes with no.)

  • 1
    Tried and failed with the same errors. This hadn't crossed my mind to try though, so thanks for your input! Jul 20, 2019 at 21:07

I would give this batch file a try:

@echo off


attrib -r %hdd%\*.* /s
del /f /q THEEXE.exe
del /f /q THEOCX.ocx


Where hdd is your drive letter or whatever folder those files are in - if it's not deep in a subfolder you can bypass the variable here altogether and just use the drive letter/path; attrib will try to remove the read-only setting from your %hdd% and all of its subfolders; and each del command will attempt to quietly delete the files and ignore read-only attributes. Make sure you change the hdd variable and the names of the .exe and ocx files, then you can attempt to run this as admin or as user and see if either help.

Reference: attrib, del

  • I've received an Access Denied error from your code. No dice there. :\ Jul 20, 2019 at 21:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .