Delete Locked File Using Command Prompt
In general, Windows 10/11 comes up with “File in Use” or “File is Locked for Editing” error, if any User tries to delete a Shared File while it is still being used by another User. In certain cases, Windows operating system can prevent a File/Folder from being deleted, even if the File/Folder was created by a User having full rights or permission to View, Edit and Delete Files. In such cases, you should be able to delete the Locked File or Folder using Command Prompt with Admin Privileges.
1. Delete File Using Command Prompt
Any File, located anywhere on the computer or the network can be deleted by running Del/FolderPath\FileName.extension Command in the Command Prompt window.
Right-click on the Locked File that you want to delete and select Properties option in the drop-down menu.
On Properties screen, switch to Details tab and note down the Folder Path.
In this case, the Locked File Test.rtf is located at Folder Path C:\Users\Username\Desktop. 3. Next, type CMD or Comm in the Search bar > right-click on Command Prompt in the search results and select Run as Administrator option.
- On Command Prompt screen, type del FolderPath\FileName.extension and press the Enter key.
Once the Command is executed properly, the File will be immediately force deleted and removed from your computer.
Delete Locked Folder Using Command Prompt
Any Folder located anywhere on the Computer or Network can be deleted by running rmdir /s /q FolderPath\FolderName Command.
Right-click on the Locked Folder that you want to delete and select Properties option in the drop-down menu.
On Properties screen, you will find the Folder path listed next to the Location Entry.
Next, open Command Prompt as Admin > type rmdir /s /q FolderPath\FolderName and press the Enter Key.
Once the Command is executed, the Folder will be immediately Force Deleted and removed from your computer
How to Change Ownership of File or Folder in Windows 10 Change Windows 10 Password Using Command Prompt