Archive: Reading an environment variable at compile time


Reading an environment variable at compile time
Hi all

I have a NSIS question which is probably due to my lack of understanding of the system. Forgive me if it has been asked before, I tried to search for it but I don't really know what to search for.

Basically here is the problem: I am writing a .nsi script to install an executable called 'opde.exe' and a config file called 'opde.cfg'. Both files are located in the same directory as the nsi script. So far so good, I was able to do so. But I also want to include in the installer a readme.txt which is not in the same directory as the nsi...its directory can change, but the environment variable %TXT_DIR% always points to it. I tried the following code:


var TxtPath
...
...
...
Section "opde (required)"

SectionIn RO

SetOutPath $INSTDIR
File opde.exe
File opde.cfg
ReadEnvStr $TxtPath TXT_DIR
File $TxtPath\readme.txt
...
...

But it does not work. At compile time I get "File: "$TxtPath\readme.txt" -> no files found.". I think this is because "ReadEnvStr" is a run-time command, it reads the environment variable of the target machine (the machine the installer is running on).

I tried "File %TxtPath%\readme.txt" but it didn't work either.
How can I get the script to read the environment variable of the development machine, at compile time?


Any help would be greatly appreciated.

Cheers.


Found the problem. Thanks guys.


Take a look at the compile time commands , in particular you want the syntax for environment variables at compile time.

File "$%TxtPath%\readme.txt" should work.