Search code examples
nsisdelete-file

Nsis installer to delete files either through a post section or on the close button in a custom dialog


I have an installer that goes to a specified network location to install some add-ins before it installs the main program. I need to figure a way to have nsis delete those files after the close button is clicked.

I tried to setup a post section and could not get it to delete the files. Any suggestions on how to either capture onclick for the close button on the last custom page or some other way I would appreciate it.


Solution

  • You could do something like this:

    Function Cleanup
    Delete ...
    FunctionEnd
    
    Function .onInstSuccess
    Call Cleanup
    FunctionEnd
    
    Function .onInstFailed
    Call Cleanup
    FunctionEnd
    

    Having a final section should work as well. You should try to figure out why it is unable to delete the files. My guess is that the path is wrong or the files are locked by some other application. Process Monitor should be able to help you figure out why the delete fails...