Running Windows 10: Can't delete a 700 MB file; tried everything
The most common reasons a file cannot be removed are:
- The permissions on the file prohibit the user/process from deleting the file.
- The file is being held open by a process.
One option that potentially eliminates both of these is to have the Windows Session Manager (SMSS.EXE) remove or rename the file at system start-up. This can be achieved using the PendingFileRenameOperations (PFRO) registry key. The operation runs under the context of Local System and runs early enough at boot that the file hasn't been opened by a process that may lock the file.
This is often used by installers to guarantee files can be replaced or removed where existing files are in use.
The PendingFileRenameOperations MULTI_SZ registry value in question can be found under the following key:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager
The following screenshot is an example where four items are to be removed on the next system start-up.
The space following an entry dictates that the file will be removed. If there is entry after the line (no space) then it is a rename operation. You can think of the lines as pairs of two entries.
Sysinternals have the following command line tools to interact with this registry value:
- PendMoves
- MoveFile
PendMoves read the above registry key and displays the pending operations and MoveFile calls the MoveFileEx API with the flag parameter set to MOVEFILE_DELAY_UNTIL_REBOOT.
If there are issues with one or more of the PFROs being actioned at start-up, the log file can be found here: %SystemRoot%\PFRO.log, e.g. C:\windows\PFRO.log.