Page 1 of 2
Using custom variables in Command line installs
Posted: Tue May 16, 2006 3:04 pm
by Gareth Owen
I am having a problem using custom variables in Command line installs.
Requirements.
A custom variable, for instance $SERIALNUMBER$ can be entered using the command line at runtime, using SERIALNUMBER=xxxxxxx
This might or might not be supplied in the commandline.
I have tried to then use this variable in my code, to check the value, for example using and IF statement, SERIALNUMBER = xxxxxxx
The install will not compile as I have not defined SERIALNUMBER in the script
If I include a SERIALNUMBER= statement in the code, the value of SERIALNUMBER that I have passed in from the command line will be overwritten.
Is there any way, other than the obvious, manually parsing the command line in the script to try to pull out the variables, to achieve this?
It would be nice if I could define my variables before the script, and before the Command line is parsed, using default values,
then I could easily check if the SERIALNUMBER variable has been set.

Posted: Tue May 16, 2006 8:59 pm
by MichaelNesmith
If you are silently running the setup, variable values will be locked-in to the values specified at the command line, so this prevents the problem you are experiencing.
Posted: Wed May 17, 2006 1:35 am
by Gareth Owen
So for the case of silent installs, setting a variable in script will have no effect?
So for silent installs
Case 1
Variable is set in command line
At begining of script, variable is set, but the value is ignored in favor of the command line value
Case 2
Variable is not set in the command line
At the begining of the script the variable is set to the value in the script.
Ok, I can live with that.
Although it would be nice if we had the option of setting variables using the command line for non-silent installs, but in this case, you would just be setting the initial value of the variable.
Posted: Wed Jun 14, 2006 11:01 am
by fletcherjames
1. Please confirm or correct my understanding of the above, which is that:
a) once a variable appears on a command line in a silent install, any Set Variable statements in the script, for that variable, are disabled, and
b) if it's NOT a silent install, then any variables on the command line are ignored (which means that there's no way to use a variable to modify the behavior of any dialogs).
2. In a silent install, are the dialogs executed in a hidden fashion, or are they skipped? In other words, if a dialog places information from MYVAR_A into TextBox1, and then transfers it from TextBox1 to MYVAR_B, and you run in silent mode, will the data transfer take place?
3. Is there any way to supply command line parameters to a Debug run?
Posted: Wed Jun 14, 2006 1:05 pm
by fletcherjames
Correction to 1b, above: At least in Version 6, the variable value assignment works just fine from the command line, even if you're not in silent mode.
Posted: Wed Jun 14, 2006 5:03 pm
by fletcherjames
Correction to Correction: My test script had a bug. As stated by Michael, back in May, variable values are NOT picked up from the command line unless the /s switch is used.
Posted: Thu Jun 15, 2006 8:45 am
by MichaelNesmith
1. You may still read the command line using If and Contains.
2. Depends on how the transfer takes place. When silent dialogs are skipped, they are not shown.
3. You can override the CMDLINE variable in the setup script to simulate passing in a command line.
Posted: Thu Mar 15, 2007 10:10 am
by Immelman
I am also attemting to parse a variable value to my exe using the commandline. According to the help documentation you can do the following: <setup> <VARIABLE_1>=<VALUE_1>
Now the objective that I need to achieve is to only install one file to the desktop if I set a commandline variable to true and then ignore all the other files to install.
So I reasoned that I could put the following argument into my script:
Code: Select all
Set Variable SECRET to FALSE
IF SECRET Equals TRUE
Install Files myText.txt to $DESKTOPDIR$
Terminate Installation
END
And then after compiling the exe do the following...
Is this possible? And if so can anyone provide an example?
Posted: Mon Mar 19, 2007 9:02 am
by JeffryPaul
Here's how I check for and initialize command line parameters:
Set Variable COMMANDLINE to $CMDLINE$
If COMMANDLINE contains (ignore case) MYPARAMETER=
Set MYPARAMETER=$MYPARAMETER$
Else
Set MYPARAMETER=
End
Hope this helps...
Jeff
Re: Using custom variables in Command line installs
Posted: Tue Mar 01, 2011 5:46 am
by ohali
Thanks for this suggestion.
It would be helpful if the InstallAware-Team could add this to the documentation, because the documentation is not correct at the moment. It states
To set the values of setup variables from the command line, possibly overriding their default values in the process, specify the variables and their values as follows:
<setup.exe> <VARIABLE_1>=<VALUE_1> [ ... <VARIABLE_N>=<VALUE_N>]In the above example, setup.exe denotes the main setup executable, VARIABLE_1 is the name of a variable to set, and VALUE_1 provides the value the variable is set to receive.
There is no word that this is only true for silent installs.
Re: Using custom variables in Command line installs
Posted: Tue Jul 12, 2011 10:17 am
by Obliterator
I use variables via the command line without problem.
They work for me without requiring silent mode.
However, this might be down to the way I use the variables.
Rather than assigning them a default value, I check for them being defined like so:
if Variable MYVAR is Defined
... use the command line variable
else
... do something else
end
I can then simply call with a command line parameter to set the variable:
Setup.exe MYVAR=TRUE
Re: Using custom variables in Command line installs
Posted: Wed Aug 10, 2011 4:57 am
by alibaba
I also discovered the problem that the LANGUAGE parameter cannot be set through commandline in interactive Mode. Only if I pass /s I can set LANGUAGE variable by passing LANGAUGE=German for instance.
An other problem is that I am not able to set the language variable. I will set this variable to English, to use it later on. Could this be because I am using a setup script that is only in english (not localized to other languages and no language selection box)? But than I do not understand why the variable does not hold the value English?
In a one-language (English) setup the variable LANGUAGE is defined but holds an empty string, and it is not possible to overwrite the value...
I am using IA10.10.
Re: Using custom variables in Command line installs
Posted: Wed Aug 10, 2011 11:24 am
by giaviv
Hi,
The LANGUAGE pre-defined variable (not the compiler variable) will always hold an empty string in a non-multilingual setup.
Therefore, when it's value is an empty string, changing its value won't do anything.
Is the setup that you are trying to set its LANGUAGE variable via the command line localized?
Re: Using custom variables in Command line installs
Posted: Thu Aug 18, 2011 1:20 am
by alibaba
The setup is a non-multilanguage setup.
It is not command line localized, besides I do not know how to do such a localization. I only know the common way through the IDE.
My thought was that a one-language setup always holds the default language in the LANGUAGE (pre-defined) variable.
What is the LANGUAGE compiler variable?
Thank you giaviv!
Re: Using custom variables in Command line installs
Posted: Thu Aug 18, 2011 8:53 am
by giaviv
Hi,
It is a little confusing, but the #LANGUAGE# (compiler) and $LANGUAGE$ variables are two different things.
#LANGUAGE# represents the default language that the installation is built in. The default language is used to initialize the setup user interface in multi-lingual installations whereas the $LANGUAGE$ variable holds the active language in multi-lingual installs (or an empty string otherwise).