Hi there, I am fairly new to NSIS but have got some good results from it over the last couple of weeks.
I am looking to create a dynamic installer (for software patches) which has a bunch of template actions (add files, delete files, add regkey, delete regkey) and reads in the entries to use from a text file. This is working nicely using hardcoded filepaths, however, I am looking to now use variables in the text file that are defined in the .nsi file.
The application that I am looking to install has 2 separate install paths that are totally independent of each other. i.e. The actual application is stored to one path (known in the .nsi file as $DIR_APP), and the configuration is stored elsewhere (stored as $DIR_CONFIG) based on where the user chooses from the 2 separate installer directory pages.
I want to be able to define the text file something like:
$DIR_APP\SomeDir\test.txt
$DIR_CONFIG\SomeDir\test2.txt
but NSIS does not seem to resolve the $DIR_APP and $DIR_CONFIG to its actual stored variable values. Is there any way to do this?
Kind Regards,
Aaron
Using Variables in a Text File
3 posts
Variables are only resolved when they are used in the .nsi script, they aren't resolved if they are read in by the installer (it's just text). They can be resolved if they are written to a text file from the installer, they will appear as full paths in the text file.
Is this similar to what your after? (I haven't tested it as I'm using linux at the moment).
Is this similar to what your after? (I haven't tested it as I'm using linux at the moment).
Name "type install"
OutFile "type install.exe"
Var DIR_APP
Var DIR_CONFIG
InstallDir "$PROGRAMFILES\type install"
Page Directory "" "" dirLeave1
Page Directory "" "" dirLeave2
Page InstFiles
Function dirLeave1
StrCpy $DIR_APP $INSTDIR
FunctionEnd
Function dirLeave2
StrCpy $DIR_CONFIG $INSTDIR
FunctionEnd
Section
DetailPrint "DIR_APP=$DIR_APP"
DetailPrint "DIR_APP=$DIR_CONFIG"
; read in your relative paths from here, so your output paths will
; look something like this:
; SetOutPath "$DIR_APP\$relative_path_from_text_file"
; SetOutPath "$DIR_CONFIG\$another_relative_path_from_text_file"
SectionEnd