By default, the Windows operating system does not allow you to delete files accessed by the active program. This is a useful feature, although it does not allow deleting, for example, malicious files. There are three ways to delete locked files.
Steps
Method 1 of 3: End the explorer.exe process

Step 1. End the explorer.exe process
This process is associated with Windows Explorer and does not allow you to delete locked files. After completing this process, you should be able to delete the file via the command line. Open Task Manager by pressing Control + alt = "Image" + Delete. Go to the Processes tab and highlight explorer.exe. Click End Process.

Step 2. Open a command prompt window by clicking "Start" - "Run"
In the window that opens, type cmd and press Enter. Change to the directory with the file to be deleted using the cd command, for example, cd C: \ Documents and Settings \ My Documents \ filename.

Step 3. Delete the locked file via the command line by entering the command del filename

Step 4. Restart the Explorer process
To do this, open the Task Manager and click "File" - "New Task". Enter explorer.exe and click OK. Or just restart your computer.
Method 2 of 3: Via Windows Recovery Console

Step 1. Boot your computer from the installation disc
Turn off the computer, insert the Windows installation disc into the optical drive, and then turn on the computer. The system will boot from the installation disc.

Step 2. Enter the Recovery Console
Recovery Console is a system troubleshooting application. When the message “Welcome to the installer” appears on the screen, press the R key to launch the Recovery Console.

Step 3. Delete the locked file
In the recovery console, go to the directory with the file to be deleted using the command described in the previous section. Then delete the file via the del command and enter exit to exit the recovery console. Reboot your computer.
Method 3 of 3: Via Unlocker

Step 1. Download and install the free Unlocker program, with which you can easily remove locked files

Step 2. In Windows Explorer, navigate to the directory with the file to be deleted
Right click on the file and select "unlocker" from the menu. Unlocker will launch and display information about the locked file.

Step 3. Delete the locked file
In the Unlocker window, click "Unlock All". This will remove restrictions on access to the file. Close the Unlocker window and delete the file in Windows Explorer.