How to force the deletion of a locked file that has no locking handle on Windows?

6

1

When I try to delete the file, using the GUI it says

The action cannot be completed because the file is open in another program

And using the del /f /q command line it says

Access is denied

I have tried unlocking the file with Unlocker, as well as trying to locate which process is using the file with the Resource Monitor or the Process Explorer, but no locking handle was found in either case.

I am able to rename or move the file, but not to delete it or change its content.

J. Doe

Posted 2016-10-16T19:25:39.990

Reputation: 63

You can't edit/delete it even after copying/moving/renaming? If so, its either virus/antivirus or NTFS file permissions.

– PTwr – 2016-10-16T20:10:42.977

I am the owner of the file and have the full read/write permissions of it. And disabling the anti virus doesn't doesn't unlock the file – J. Doe – 2016-10-16T23:06:37.927

Answers

4

We are always glad to help, but just to double-check (since you didn't elaborate), are you certain that this isn't a critical operating system file?

If you are confident that this isn't an essential OS or application file, you can always utilize a Linux Live CD of some type and navigate to the file accordingly. Under those circumstances, it won't be constrained by the Windows operating system and can easily be deleted.

If you are trying to completely delete the Windows.old folder, that is understandably frustrating. I have encountered similar problems following a Windows 10 upgrade, and was finally able to delete it by booting into a command prompt. Try utilizing the following method:

  1. While logged into Windows 10, open the Run window by holding WinKey + R
  2. Type shutdown /r /o /f /t 00 in the subsequent window, then press Enter
  3. After the system reboots, click on Troubleshoot

    Click on Troubleshoot

  4. Click on Advanced Options

    Click on Advanced Options

  5. Click on Command Prompt

    Click on Command Prompt

  6. The ensuing window will ask you to Choose an account to continue

  7. Select a local administrator account, type in the appropriate password, and click on Continue
  8. Within the command prompt, type diskpart and press Enter (as seen below)
  9. In the command prompt, type list volume and press Enter
  10. From the listed volumes, look for and verify the drive letter of your Windows 10 drive.
  11. In the command prompt, type exit and press Enter

    Command Prompt Window

  12. Ensure that you substitute "D" in the command below with the actual drive letter of your Windows drive as displayed from step 10 (above).

  13. To delete the "Windows.old" folder, type RD /S /Q "D:\Windows.old" and press Enter
  14. Close the command prompt window.
  15. Back at the Choose an option window, click on Continue to restart the computer.

(Source: How to Delete Windows.old Folder in Windows 10)

Run5k

Posted 2016-10-16T19:25:39.990

Reputation: 13 092

It was a file from the Windows.old folder, I ran the Disk Clean-up, which deleted everything in this folder except this file – J. Doe – 2016-10-16T23:05:02.273

That definitely paints a different picture, and I have previously encountered the exact same scenario. I updated my answer with what I did before to solve that problem. – Run5k – 2016-10-16T23:23:12.933

Great that worked! And good job on adding the screenshots that helped – J. Doe – 2016-10-22T00:54:00.433

Glad to hear it! Again, I encountered the exact same scenario after my first Windows 10 upgrade, and that tutorial worked for me, too. – Run5k – 2016-10-22T02:15:08.997

In Windows.old folders this is usually (but possibly not always) due to a driver locking the file. In the Device Manager, find the device and disable it, then delete the file (or take ownership and delete), and then re-enable the device. Lots simpler than getting into the recovery console. – music2myear – 2017-07-12T17:55:43.787

1Thank you, I have an ACER laptop with precious little space and used your method to delete C:\Recovery\Customizations\usmt.ppkg which was 3.4G more than I could afford to spare. I used del vs. rd since it is a file, not a folder. – Oliver Williams – 2017-10-30T22:42:32.657

Your answer contains image from another forum. It can be added from VirtualBox. – Biswapriyo – 2018-08-25T17:27:38.257

@Biswapriyo, yes it does... and that's why I specifically referenced the TenForums article at the end of my answer. I appreciate your feedback, but I'm not too worried about having the TenForums watermark on the screenshots. My top priority when I posted this answer was technical accuracy, not pristine screenshots. – Run5k – 2018-08-25T17:43:23.017

0

You can use MoveFile from Microsoft SysInternals utilities.

It allows you to schedule a move or delete at next reboot. The operation will take place before the files are referenced.

RobertKenny

Posted 2016-10-16T19:25:39.990

Reputation: 136