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

8

2

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

user14872

Posted 2009-10-21T18:03:07.253

Reputation:

Answers

14

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.

Snark

Posted 2009-10-21T18:03:07.253

Reputation: 30 147

Personally I prefer MalwareByte's FileAssassin - http://www.malwarebytes.org/fileassassin.php

– Dentrasi – 2009-10-21T18:59:44.893

That sounds like what I need. I will look at it tomorrow and accept the answer if that's it. Thanks! – None – 2009-10-22T01:40:42.917

Sorry i haven't gotten back to this yet, but don't worry I won't forget :) – None – 2009-10-23T17:23:09.100

I been on another project for the past two weeks, but I will get back to this eventually I promise lol. – None – 2009-11-06T00:56:05.260

Thanks Snark! That was the correct registry key that I needed, and I was able to discover the ::MoveFileEx function by looking at that source code; It was exactly what I needed!! Thanks again!. – None – 2009-11-09T02:10:16.333

1

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\""

Malcolm

Posted 2009-10-21T18:03:07.253

Reputation: 11

This puts the "Delete on Reboot" item in the right-click menu, but it doesn't seem to actually delete the chosen files on Windows 10. Any idea why? – vertigoelectric – 2016-09-03T00:49:24.077