Archive: Check for files to be removed on reboot?


Check for files to be removed on reboot?
Is there any way to determine if there's any files pending removal on reboot?

What I mean is, say that a program is removed, and leaves a file around that needs to be removed on reboot.

Now, in a separate process, I want to reinstall the program (or install another program), but won't want to if there are files/directories pending removal. Is there any way to tell this? I'm guessing there's a registry key or file somewhere that lists the files to remove on reboot, but I wasn't sure what it was.

Also, is the mechanism that NSIS uses to specify this different than other Windows installers?


The easiest solution is to set a flag denoting that an uninstall has been performed. Any files that are still present must be pending deletion on reboot.

On install if the uninstall flag has been set and some files are present you can ask the user to reboot.

Stu


Thanks for the reply!

So what you're saying is do this:

During uninstall:
- Open a file (probably %TEMP%\flagfile)
- Try to delete it (Delete %TEMP%\flagfile)
- This will fail, so it will be flagged for deletion on reboot
- Close the file

During Install
- Check for %TEMP%\flagfile
- If it exists
- An uninstall was done without a reboot. Tell the user to reboot before continuing. On the reboot, flagfile will get removed.


That sound right? Is there any way to know if there are any files which couldn't be removed? If everything removed successfully, I wouldn't want to create the flagfile.

Also, how does NSIS tell Windows to remove these files on reboot? A file somewhere or a registry key? Perhaps it would be easier to loop through that and see if there are any files in the directories I care about that are pending a reboot?