The definition of locked files varies widely. Any file used by a running application or process cannot be deleted or edited. And thus, such files are referred to as locked files by many users and developers.
Read-only files also cannot be edited and can be confused with locked files. Or if your computer is in a network and you don’t have ownership of the shared files, it may be locked from deleting.
Anyways, in this article, we’ll discuss force deleting all types of locked files in Windows.
How to Force Locked Delete Files on Windows?
Using keyboard shortcuts would be effective in bypassing the recycle bin and permanently deleting your files. To do so, you can select the desired file and press the Shift + Del keys on your keyboard. Some files may even want admin permissions. However, locked files may not co-operate with any usual method of deletion.
So, you can try the method listed below to delete locked files:
Use DEL Command
Commands in the command prompt provide you with the privilege to easily delete files. It can also force delete files open in any application.
Follow the given steps to delete a locked file using the command:
- Press Windows + R keys.
- Type cmd and hit Ctrl + Shift + Enter.
- Click on the Yes button.
- Now, run the command:
del “File path”.
Like, if your file is file.txt in the E drive, the path would be del
End Task, Then Delete
We cannot delete the files open in some application or process in the background. As already mentioned, applications lock the in-use files to prevent any unwanted hindrances in their operation. Thus, you will have first to close such apps or processes from the Task Manager, and then only you will be able to delete files.
If you are aware of the particular app by which the file is being utilized, then follow:
- Press the Ctrl + Shift + Esc keys.
- Within the processes tab, Right-click on the potential app which may be using your file.
- Choose the End task option.
Various processes of a single application may also use some files. And sometimes, these processes won’t close just by ending the application. So, proceed to the end task for all such known processes. But you shouldn’t just try to shoot in the dark, as ending any important process can cause severe inconvenience in the functioning of your computer.
Once you stop all such processes opening your file, you can easily delete it with the above-mentioned shortcut, i.e., Shift + Del. Or, you can also use the traditional method of right-click and then Delete, which will dump your file into the recycle bin.
Locate the Process with Process Explorer
Task Manager doesn’t specify which process is being executed under which application. So, to ease out, Microsoft has a different application called Process Explorer, which can be downloaded through their website. Download and install it as per the instructions.
Then, follow the listed steps to locate and delete processes:
- Double click the
.exefile or Desktop icon.
- Click on the Run button.
- Locate all the unnecessary process clusters under stoppable applications.
- Right-click on each of them, and choose Kill Process.
- Go with the OK button on dialog box.
After killing the unwanted processes, you can use the manual or command prompt methods to delete the files.
Close the Open Handles and Delete
With the use of handles, processes may access any permitted resources within the system object by calling out the pointers. And open handles may lock the associate files. Simply, just know that there may be some open handles assigned to the file that forbid deleting it. So, first, you need to halt the process for all the handles and then delete the file.
To stop all the handles, follow the steps mentioned below:
- Press the Windows + R keys, type
resmon, and hit Enter.
- Go to the CPU tab.
- Search the file name in the search bar of the Associated Handles section.
- This will list all the open handles assigned to the file. You can right-click on each handle and select End Process.
- Again, Click on the End Process button on the dialog box.
Now, delete the desired file by either using the above command or the traditional method.
Delete in Safe Mode
Safe Mode is the simplistic launch state of Windows. Only very essential drivers operate in default settings, closing all the third-party background apps. So, safe mode highly minimizes the chance of your file being locked by any app/process/handle. Eventually, making it convenient to delete files.
Follow the given steps to enter the safe mode on your computer:
- Go to the Start menu and click on the Power icon.
- Hold the Shift key and choose Restart, which will load Windows Recovery Environment.
- Click on the Troubleshoot option.
- Go with the Advanced options.
- Choose Startup Settings.
- Hit the Restart button.
- Select the number associated with Safe Mode, as per the screen.
Windows will start on Safe Mode once done. You can then navigate to the file location and perform the manual click method or the shortcut one. Or, the command prompt method would be more effective. Follow the steps mentioned above in the Use Command section to continue force deleting files.
Delete Read-Only Files
Files can be marked as read-only on pc to resist editing and deletion. And since they can’t be deleted, some people may confuse read-only files with locked ones. Either way, to delete read-only files, you can change remove the read-only status and proceed.
Follow the steps below to swap the status:
- Right-click on the file and choose Properties.
- Untick the box for Read-only.
- Click on the Apply button.
- You can also use the del command to force delete read-only files. Just add the /f flag, for example,
del /f “filepath”.
Take Ownership to Delete
For a shared file whose ownership was already overtaken by another user in a local network, you may need first to take back the ownership to delete it. It would be easy if you’re logged in from the network administrator’s PC.
- Open command prompt in administrator mode
takeown /f “file location”
Now, you can use manual methods to delete the files.