Archive: Copy file directory structure instead of archive into exe


Copy file directory structure instead of archive into exe
Hi, I'm fairly new to NSIS etc, and I've got a question. I notice that a lot of the time spent by my installer is on verifying the exe file (as it gets quite large with 400mb's of files archived in there). Anyway, what I was wondering is if there's an option you can set that basically just copies a directory structure from the source location (in this case, the CD drive) to the install directory rather than adding all the files into the exe file when the script is compiled, and then the installer extracting them from there?

I imagine this would significantly reduce the installation verification time, and also the file copying stage would be a little quicker as it is just a straight copy rather than extract then copy.

Thanks for any help :D

- Chris


You have to get the path to your source files, and the path of where you want to install your files, then use CopyFiles (4.9.3.2 in nsis manual) :).


You can also disable installer verification using CRCCheck off.


Thanks for your help. I did see the CopyFiles option, but couldn't see an obvious way of finding where the CD drive is on the system, and hence find where the source files would be.

Disabling the CRC Check should provide enough of a boost though. I didn't notice that one before, so thanks :D


Useful with $EXEDIR if you want to copy from installation media, or to copy from one place to another on the system.
I am pretty sure $EXEDIR refers to where the installer .exe is, because that would mean the installer is on the cd, so your source files would be like:
CopyFiles "$EXEDIR\sourcefiles\*.*" "$INSTDIR"
Here is a working example:

Name "CopyFiles test"
OutFile "CopyFiles-Test.exe"

!include "MUI.nsh"

!insertmacro MUI_PAGE_INSTFILES

!insertmacro MUI_LANGUAGE "English"

ShowInstDetails show

Section "Files"
;create a file in the exedir to copy
FileOpen $0 "$EXEDIR\Hi.txt" w
FileWrite $0 "Test Text"
FileClose $0

;copy files in $EXEDIR to hi folder on desktop
CreateDirectory "$DESKTOP\hi"
CopyFiles "$EXEDIR\*.*" "$DESKTOP\hi" ;copies files recursivly

;prevent installer from closing
SetAutoClose false
SectionEnd