Search code examples
filecopynsis

Copy file before include it in the installer package NSIS


For example I have a config file in D:\Project\InstallerPro\Platform\Windows8\Web.config I need to move that file to D:\Project\InstallerPro\Web\Configuration\Web.config if the windows version is windows 8

After that, the installer will be generated from a nsi script in D:\Project\InstallerPro\PROinst.nsi

Is it possible to copy the files (not manually) before compiling it into an installer using NSIS?

I want to do something like this:

CopyFiles ".\Source\Platform\Windows8\Web.config" ".\Source\WEB\Configuration\Web.config"

Solution

  • CopyFiles is a runtime command, i.e a command that will run during the installer execution and not during the installer creation.

    You could use the !system command that is executed during the compilation of the installer, e.g.:

    !system `copy "c:\Source\Platform\Windows8\Web.config" "c:\Source\WEB\Configuration\Web.config"`
    

    You will need to use absolute paths as the current working dir is from makensis.exe and not from the script being compiled.