An error that appears on the computers of everyone who tries to clean their hard drive or remove a virus is: Can't delete (your file): Access denied. ' Make sure the disk is not full or write-protected and that the file is not in use at this time. ' There are a few different methods that you can employ to permanently delete this file, but before you go through all the steps, it is important that you make sure that the file you are trying to delete is not actually in use. If this is not the case, there are free third-party applications and simple command line tools that you can use to forcibly delete a file or folder.
Steps
Method 1 of 3: Close open tasks

Step 1. Close all the programs that you have open
This error generally appears because a program has access to the file you are about to delete. For example, if you try to delete a document that you have open in Word or a song that you listen to, an error message will appear on the computer.

Step 2. Open the task manager
Press the Ctrl, alt = "Image" and Del keys at the same time and select the task manager from the menu that appears. Then click on the "Username" tab and look for the records that are identified with the name of your account. You can terminate most of the programs that appear in the task manager without causing a computer crash.

Step 3. Close the programs you recognize by clicking on them and pressing the "End process" button
If closing one of the programs makes the system unstable, restart the computer to solve the problem

Step 4. Restart the computer
If you restart your computer, you can often stop programs from accessing the file you are about to delete. Restart the computer and try to delete the file before opening any other programs.
Method 2 of 3: Use a third-party program

Step 1. Look for a program that unlocks computer processes
Some popular options are: Process Explorer, LockHunter, Unlocker or Lock UnMatic and Mac OS File Unlocker for Mac. All of these programs are free and are integrated into the Windows interface. If you choose to use Unlocker, be careful when browsing their website, because there are many misleading advertisements that can install malware on your computer.

Step 2. Install the program
The installation processes for both programs are relatively straightforward. Unzip the files (if necessary) and open the "Setup" or "Install" application. The default settings work for almost all users.
Some programs may try to install toolbars for Internet browsers. Make sure to uncheck the corresponding boxes if you don't want to install these toolbars

Step 3. Right click on the file you want to delete
Then select the program to unlock processes from the drop-down menu. This will open a new window with a list of all the programs that have access to the file.

Step 4. End the programs
Select the program you want to end and click the "End process" button. When you close all the programs that have access to the file, you will be able to delete the file without problems.
Method 3 of 3: Use the command prompt

Step 1. Locate the file you want to delete on the hard drive
If you can't find the file, use the search function. Click on the start menu and type the name of the file in the search field. In Windows 8, just start typing the file name while on the start screen.

Step 2. Right click on the file and select the "Properties" option
Uncheck all file or folder attributes.

Step 3. Make a note of the file location
You'll have to relocate it later, when you forcibly delete it at the command prompt.

Step 4. Open the command prompt
Click on the start menu and type "cmd" in the search field.

Step 5. Close all the programs that you have open
Close all open programs, except for the command prompt.

Step 6. Open the task manager
To do this, you can press the Ctrl, alt = "Image" and Del keys at the same time and select the task manager from the menu that appears. If not, you can go to the start menu, press "Run" and type "TASKMGR. EX".

Step 7. Click on the "Processes" tab within the task manager
Click on the "EXPLORER. EXE" process and press the "End process" button. Then minimize the task manager, but leave it open.

Step 8. Return to the command prompt window
Return to the command prompt window. Here you can forcibly delete a file or folder with a basic command line tool. While both files and folders can be erased in basically the same way, there are subtle differences in the command to use.
Step 9. Find the path:
C: \ Documents and Settings \ Your username>. This will be at the command prompt.


Step 10. Run the command
In the command prompt window, enter: cd Documents after your username.

Step 11. Delete the file
After "My Documents", enter the delete command followed by the name of the file you want to delete. For example: "del My File.exe".

Step 12. Use the "DEL" command to delete the file
The final command should look like this: C: \ Documents and Settings \ Your username \ My Documents> del My File.exe.

Step 13. Delete a folder
If you want to delete a folder and not a file, use the "RMDIR / S / Q" command instead of the "del" command. It should look something like this: C: \ Documents and Settings \ Your username> rmdir / s / q "C: \ Documents and Settings \ Your username \ My Documents \ My File".

Step 14. Press the alt = "Image" and Tab keys
Thus, you will return to the task manager, where you can select New task and then type "EXPLORER. EXE" to bring up the Windows interface.

Step 15. Close the task manager
The file is supposed to be deleted, but if you want to verify it, search for it by going to Start and then entering it in the search bar.
Advice
- To learn more about DOS commands, type "HELP" (without quotes) at the command prompt window or search the Internet.
-
To go back in the directory path via the command prompt window, use the following command:
CD.
Warnings
- This trick will not work if a program uses the file you are about to delete. For example, if you want to delete a song that you listen to on your computer, you have to close the music player and delete the file.
- Do not end any other process apart from "EXPLORER. EXE", as it may cause undesirable results such as loss of information, instability in the system and failure or corruption of the operating system.