Archive: Use dynamic string with "File" instruction


Use dynamic string with "File" instruction
I'm trying to include files in my installer that are based in a possibly changing location. The location is stored in an environment variable. I tried:

ReadEnvStr $0 JAVA_HOME
File /r "$0\jre\*.*"

But the compiler complains that there are no files in "$0\jre". I've tried with the $0 inside the quotes, outside, I tried using StrCpy, etc. I've even tried

ReadEnvStr $0 JAVA_HOME
!define JAVA_HOME "$0"
File /r "${JAVA_HOME}\jre\*.*"

but it also complains that there are no files in "$0\jre".

How does one do this?

Ken DeLong


Variables are runtime only. The compiler can't know the value of JAVA_HOME ahead. You should write a batch file that will invoke makensis.exe with "/DJAVA_HOME=%JAVA_HOME%" or have a program write the contents of JAVA_HOME into a header file, execute that program using !system and include the file it produces using !include.