Archive: Overwrite File In Use


Overwrite File In Use
I have a nsis installer that is basically an update. I need to overwrite a file that is currently in use. I have been using a windows executable (inuse.exe) to accomplish it but I'm wondering if there's a way to do it with nsis directly.


Rename /REBOOTOK is what you need. Extract the new file with another name and use Rename /REBOOTOK to copy it over the old file after reboot. The Library macro does this. You can take a look at its source code in Include\Library.nsh.


Thanks, I will try this.


I'm unable to find documentation on how to determine that a file is in-use with NSIS. Am I missing something, or is there a plug-in out there that does this?


Use SetOverwrite try and check the error flag after calling File. If the error flag is set, the file was not overwritten. Don't forget to clear the error flag using ClearErrors before calling File.