Search code examples
nsis

How to copy files from a path found in env strings?


trying this fails NSIS during installer building... in any way I try t put it.

readEnvStr $R0 "QT_PATH"
File $R0\bin\QtCore4.dll 
File $R0\bin\QtGui4.dll  

During installer building, i'd like to include files from a path encoded in the environment string QT_PATH. how can this be done?


Solution

  • The File instruction takes a path on the local system you are compiling on. SetOutPath is used to set the destination directory at run-time:

    Section
    ReadEnvStr $R0 "QT_PATH"
    # Might be a good idea to validate the path here and fall back to some other location if necessary
    SetOutPath "$R0\bin"
    File "c:\myinstallersourcefiles\QtCore4.dll"
    ...
    

    Or the path on your local system: File "$%QT_PATH%\bin\QtCore4.dll"