Is there a registry key to tell windows to delete a file at next startup?

Solution 1:

Yes, the values are stored in the registry key

HKLM\System\CurrentControlSet\Control\Session Manager\PendingFileRenameOperations

but you'd better use a tool for this, like MoveFile from SysInternals, or MoveLatr from BitSum (C source code provided for the latter), which do the registry editing for you.

Solution 2:

Add this to your registry and use the right click menu:

[HKEY_CLASSES_ROOT\*\shell\Delete on reboot\command]
@="CMD /E:OFF /C REG ADD HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\Currentversion\\RunOnce /v \"Del %1 OnNextReboot\" /d ^\"cmd.exe /c DEL /F /Q \\\"%1\\\"\" /f\""

[HKEY_CLASSES_ROOT\*\shell\Open]

[HKEY_CLASSES_ROOT\Folder\shell\Delete on reboot\command]
@="CMD /E:OFF /C REG ADD HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\Currentversion\\RunOnce /v \"Del %1 OnNextReboot\" /d ^\"cmd.exe /c RD /S /Q \\\"%1\\\"\" /f\""