Archive: How to copy locked/in-use files and prompt reboot?


How to copy locked/in-use files and prompt reboot?
I know, I know... Kill me! I've read and read and searched and searched and looked in other scripts. My brain is not running optimally today. Not to mention I'm brand new to NSIS (I LOVE IT!) and I'm being pressed to write a pretty intensive install in the next two days.

I'm just trying to reinstall with a file that might possibly be open/locked (tray applet). I don't want the install to prompt for Abort/Retry/Ignore, but to flag and prompt for reboot so the file can be replaced upon rebooting.

I really would rather not kill the process either, if I don't have to.

Can someone assist with what to call to make this so? I know it's something simple I just missed.

Thanks in advance!


Search for information regarding HKLM\SYSTEM\CurrentControlSet\Control\SessionManager [PendingFileRenameOperations].


Use `SetOverwrite try` and after trying to write the file, check for errors using IfErrors. If errors exist, extract the file with a temporary name and rename it with the /REBOOTOK flag.

The UpgradeDLL is an example for this and so are the Library macros in Includes\Library.nsh.


Perfect. Thanks. . . that's exactly what I was looking for!