I am making an NSIS script which checks if a previous version of the application is installed. If so, it asks whether or not the configuration file should be imported from this previous version. So I have a global variable config file which I am trying to set at runtime depending on whether the user chooses "yes" or "no". The problem I am having is when compiling it complains with File: "${XMLConfigDir}*.xml" -> no files found. because XMLConfigDir has not been set yet. So is there anyway to set a variable at runtime?
Setting a variable at run time
The solution to my problem was to use the CopyFiles built in function rather than the SetOutPath followed by File.
There is difference between declaring variables (Var command) and symbols (defined with !define command):
Var /GLOBAL myVar ; This is variable -> use it as $myVar
!define mySymbol; This is symbol -> use it as ${mySymbol}
Try this:
!define XMLConfigDir "C:\some_path_to_XML\subdir\"
Section "Main Section"
File "${XMLConfigDir}*.xml"
SectionEnd
Symbols can be also set using /D command line switch during installer runtime.
/D switch can be also used during compilation as: makensis.exe /DmySymbol="C:\some_path_to_XML\subdir\" script_to_compile.nsi –
Amblygonite
Cheers for the info but I don't understand how it answers my question of not being able to use the File command with a variable which is unknown at compile time but determined at runtime. –
Marte
The solution to my problem was to use the CopyFiles built in function rather than the SetOutPath followed by File.
© 2022 - 2024 — McMap. All rights reserved.