- NSIS Discussion
- Varibles in File
Archive: Varibles in File
James4563
22nd February 2007 09:16 UTC
Varibles in File
Hi,
Just a quick question are you able to use variables in File.
For example
StrCpy $DISTRIBUTION_CD_LOCATION "G:\generic\bbRad distribution CD\bbRad v1.11 ib0\Enterprise\Program Files\bbRad\"
SetOutPath "
$INSTDIR"
SetOverwrite try
File $DISTRIBUTION_CD_LOCATION"bbRadCLI.exe"
>
Using the above I get the following error:
File: "$DISTRIBUTION_CD_LOCATION"bbRadCLI.exe"" -> no files found.
Usage: File [/nonfatal] [/a] ([/r] [/x filespec [...]] filespec [...] |
/oname=outfile one_file_only)
Error in script "C:\Documents and Settings\james\workspace\bbRad installer\setup.nsi" on line
75 -- aborting creation process
Is it that you must specify the whole dir to the file when using File, or have I just done something wrong with the var side of things....
Thanks
James
Red Wine
22nd February 2007 09:20 UTC
It is that you can't use variables at compile time, instead try to !define DISTRIBUTION_CD_LOCATION
James4563
22nd February 2007 09:23 UTC
What just like this,
!define DISTRIBUTION_CD_LOCATION "Path here"
Because if thats correct im still getting the same error :(
Red Wine
22nd February 2007 09:26 UTC
!define DISTRIBUTION_CD_LOCATION "D:\My Local Path"
File: "${DISTRIBUTION_CD_LOCATION}\bbRadCLI.exe"
James4563
22nd February 2007 09:28 UTC
You legend. Thanks a lot :D that works brill
James4563
22nd February 2007 11:15 UTC
Keeping to a similar topic. Is it possible to use a variable in an unistall part.
For example :
Section Uninstall
Delete "$INSTDIR\config\bbRadGateway$INI_NACS.ini"
SectionEnd
Thanks
Afrow UK
22nd February 2007 12:22 UTC
Yes but its value won't be magically copied from the installer to the uninstaller. You need to store its value in the registry or an INI file.
If its value does not change then use a !define instead.
-Stu
Red Wine
22nd February 2007 13:15 UTC
Originally posted by James4563
You legend. Thanks a lot :D that works brill
The only legend that I know around here is kichik, I'm just a consistent of...
James4563
22nd February 2007 23:48 UTC
Originally posted by Afrow UK
Yes but its value won't be magically copied from the installer to the uninstaller. You need to store its value in the registry or an INI file.
If its value does not change then use a !define instead.
-Stu
Ok thanks. So if I use !define instead will that mean I can just put it into the uninstaller? Or will I still need to store in the reg or an ini file.
Cheers for the help peeps :D
Afrow UK
22nd February 2007 23:57 UTC
!define makes a compile time constant. Once your installer is compiled, it's value is sustained in a static form wherever it's used. Variables on the other hand are used if your value needs to change while the installer is being executed by the end user. If your value will never change, then use a constant (define) and not a variable. Once you've created a constant, you can use it anywhere in your script whether it's inside or outside sections and functions.
-Stu
James4563
22nd February 2007 23:59 UTC
Well the value I want to use is acctually enter by the user in the installation config. So im guessing that I cant used !define.
Is it fairly easy to store the values into the Registry? Or would you recommend storing them in an ini file instead?
James
Red Wine
23rd February 2007 00:02 UTC
So if I use !define instead will that mean I can just put it into the uninstaller? Or will I still need to store in the reg or an ini file.
!define is ok while its value is global, hence you can't change it at run time.
Afrow UK
23rd February 2007 00:10 UTC
The registry is probably your safest bet. Use WriteRegStr and ReadRegStr.
There are pros and cons for using the registry or initialisation files, but most people would rather use the registry simply because you don't need to worry about a particular file on the hard drive.
-Stu
James4563
23rd February 2007 00:23 UTC
Cheers mate. Ill try it out and see what I can do.
Ill post back if I get anymore problems, which I probably will :D