Check if a file is scheduled to be deleted

1

1

In Windows, a program can schedule a file to be deleted when the computer restarts.

Is there a way to know if a file is scheduled to be deleted, short of restarting the computer, and checking if the file is still there?

sashoalm

Posted 2013-11-27T10:50:58.563

Reputation: 2 680

Answers

4

Yes. The MoveFileEx() call with the MOVEFILE_DELAY_UNTIL_REBOOT flag moves a file on the next reboot. If the second parameter (the new name) is NULL, the file is deleted. The list of files to be renamed in this way is stored in the registry:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\PendingFileRenameOperations

If you wanted to do this in a batch file or at the command line, I'd recommend you to use "reg /query".

carveone

Posted 2013-11-27T10:50:58.563

Reputation: 318

1

The sysinternal pendmoves tool is an easy way to do this from a command prompt too.

– mr.spuratic – 2014-06-24T08:34:20.787

I don't see this registry key on my Windows 10 install. There's a FileRenameOperations key, but it is empty even though I have files queued for deletion. – Mike Marynowski – 2018-10-12T23:50:05.323