Windows does so many things in the background without the knowledge of the users. One of these things that is carried out in the background is setting up of files for deletion on the next boot. For this, Microsoft provides a Windows API called MoveFileEx() which is used by various applications to set the files for deletion until the next boot. The purpose of this mechanism is to delete the files that are in use and cannot be deleted. With the help of this method, programs can set these in-use files for deletion as soon as Windows loads the next time you start your PC.
But how do you know which files Windows has scheduled for deletion at the next boot? With the help of a freeware called PendMoves, we can easily find out which of the files are scheduled. It is a console application and has a command line interface. It does not take any parameters and this is why it is very easy to run for anyone. We can run it by giving the command PendMoves.exe.
The output of the above command would be a list of all the files that have been set for deletion. These files are listed in the Windows Registry and PendMoves simply reads them from the registry. In the output, we see a Source file and followed by Target: DELETE which means it will be deleted.
When you boot your PC the next time, Windows will make an attempt to remove these files if possible. When successful these entries will be automatically removed.
What if you want to set a file to be deleted at next boot? This can be done by an accompanying application called MoveFile which is also a CLI application just like PendMoves. In this case the command line would be movefile [target file with full path]. For example if you want to remove C:\Windows\Temp\junk.tmp at the next reboot then you can use the command movefile.exe C:\Windows\Temp\junk.tmp.
With the help of Syninternals PendMoves and MoveFile CLI applications, we can know which files Windows has scheduled for deletion and set some of the files for scheduled deletion ourselves.
You can download PendMoves and MoveFile from https://docs.microsoft.com/en-us/sysinternals/downloads/pendmoves.