If you are unable to delete a File or Folder on your computer due to File is Locked error, you should be able to delete the Locked File using Command Prompt.
Delete Locked File or Folder Using Command Prompt
In general, Windows 10 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 10 can prevent a File or Folder from being deleted, even if the File/Folder was created by you, it is not being shared and you have the full rights or permission to View, Edit and Delete the File.
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.
1. Right-click on the Locked File that you want to delete and select Properties option in the drop-down menu.
2. 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.
4. 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.
1. Right-click on the Locked Folder that you want to delete and select Properties option in the drop-down menu.
2. On Properties screen, you will find the Folder path listed next to the Location Entry.
3. 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