Hi.
I'm new to this forum (which is excellent by the way, it contains a lot of information). I've been using NSIS for about 3 weeks, but now I stumbled upon something that I could not find an answer to in the help-docs or this forum.
I use the following code to copy some PDF files to the installation folder:
!define DOCUMENTATION_SOURCES "Documentation"
Function InstallDocumentation
; copy documentation.
CreateDirectory "$INSTDIR\${MAINPRODUCT_DEST}\Documentation"
SetOutPath "$INSTDIR\${MAINPRODUCT_DEST}\Documentation"
ClearErrors
File /nonfatal /r "C:\work\installers\Deploy\${DOCUMENTATION_SOURCES}\*.pdf"
MessageBox MB_OK "C:\work\installers\Deploy\${DOCUMENTATION_SOURCES}\*.pdf"
File /nonfatal /r "$EXEDIR\${DOCUMENTATION_SOURCES}\*.pdf"
MessageBox MB_OK "$EXEDIR\${DOCUMENTATION_SOURCES}\*.pdf"
IfErrors cannot_install
Return
cannot_install:
Call HandleInstallationError
Abort
FunctionEnd
(I can't seem to get indents on the forum...)
When I compile my code, the compiler gives the following warning:
File: "$EXEDIR\Documentation\*.pdf" -> no files found. (filename.nsh:270)
When I run the code, the two MessageBoxes contain the same output: C:\work\installers\Deploy\Documentation\*.pdf
However, using the File command containing $EXEDIR doesn't copy any documents to the output folder, while using the File command containing the hard-coded folder does.
What am I missing here?
$EXEDIR doesn't work, hard-coded path does.
6 posts
$EXEDIR is the run-time variable (compile-time doesn't have variables only defines). Use:
File /r "${DOCUMENTATION_SOURCES}\*.pdf"orFile /r ".\${DOCUMENTATION_SOURCES}\*.pdf"@Instructor: I've tried both, but the result is the same: File: "(.\) Documentation\*.pdf" -> no files found.
OK, I think I have found the problem. It was my mistake: I tried to misuse the File command.
I want to copy an unknown number of files at runtime from the EXE-dir\Documentation to some output folder. But this can (and should) not be done with the File command, because that command will include the files-to-copy in the installer file. I need some code to dynamically copy files at runtime. The CopyFiles command seems to do just that!
I want to copy an unknown number of files at runtime from the EXE-dir\Documentation to some output folder. But this can (and should) not be done with the File command, because that command will include the files-to-copy in the installer file. I need some code to dynamically copy files at runtime. The CopyFiles command seems to do just that!
You seem to have answered your own question while I was replying.
Yes, I have. CopyFiles works excellent. Thanks though.