Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Access is denied when use del /f in windows 10 64bit

I'm going to delete 1.mp3 but it gives me the error "Access is denied".

More info about file's perms:

attrib 1.mp3
A   C:\Users\Alipour\Desktop\1\1.mp3

I also used attrib -s -h 1.mp3

but still it can not be deleted by

del /f/s/q 1.mp3 > NUL

or

del /f/s/q 1.mp3

or

del /f 1.mp3
like image 728
Mohammad Alipour Avatar asked Jul 05 '17 13:07

Mohammad Alipour


People also ask

How do I fix access denied on Windows 10?

Right-click the file or folder, and then click Properties. Click the Security tab. Under Group or user names, click your name to see the permissions that you have. Click Edit, click your name, select the check boxes for the permissions that you must have, and then click OK.


1 Answers

There are several methods to remove such a file:

1. Process Explorer if the file is in use:
You can use ProcessExplorer from Windows Sysinternals to identifiy which program locks the file. Download and start ProcessExplorer and go to Find|Find Handle or DLL... Ctrl+F and enter the name of the locked file: 1.mp3.

ProcessExplorer will show you the process that is responsible for the lock because of accessing the file. If you've got the proccess kill that one and delete the file.

Example with MS Word accessing a file called LockedFile.docx:
ProcessExplorerExample


2. Safe mode boot:
Another possibility is to boot into safe mode. In pre Windows 8 era this was done by pressing F8 before Windows boots.
In Windows 8 and higher you can press Shift+F8 before Windows boots or more easily you can hold Shift and click Restart in the login screen or even in Windows. If this was too short, look here how to get into safe mode.

Once you're in the safe mode you can try again deleting that file.


3. Remove file on Windows boot via PendingFileRenameOperations:
With PendingFileRenameOperations you can rename and even delete a file on Windows boot procedure when nothing else can access and block that file. PendingFileRenameOperations will be entered in the Windows registry and consists of pairs of file paths.

You can do it manually as described below or again with a Windows Sysinternals program called MoveFile. Download that program and use it in a console window (Start -> Run or Windows-Key+R, type cmd and press ENTER).
Type movefile foo.exe "" to delete a file on reboot.

Manual method via registry:
The 1st path is the file to be renamed.
The 2nd path is the new file path. If the 2nd path is empty (0x0000) the file get's removed.

  1. Start -> Run or Windows-Key+R
  2. Type in regedit, and press ENTER
  3. Goto HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager
  4. Create a new Multi-String value: PendingFileRenameOperations
  5. Enter \??\filepath as the data (e.g. \??\C:\Users\xyz\Desktop\foo.exe)
  6. Press OK
  7. Right-click on the key, click Modify Binary Data
  8. At the end of the hex string, add 0000 (4 zeros which represent an empty string)
  9. Press OK
  10. Restart your computer
like image 168
Andre Kampling Avatar answered Oct 02 '22 21:10

Andre Kampling