Using custom variables in Command line installs

Got a problem you cannot solve? Try here.
Gareth Owen
Posts: 149
Joined: Fri Oct 21, 2005 8:42 am
Location: UK

Using custom variables in Command line installs

Post 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. :D
MichaelNesmith
Posts: 3452
Joined: Thu Dec 22, 2005 7:17 pm
Contact:

Post 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.
Michael Nesmith
Install[b]Aware[/b]
[i]Home of The Next Generation MSI Installer[/i]
Get your free copy today - http://www.installaware.com/
Gareth Owen
Posts: 149
Joined: Fri Oct 21, 2005 8:42 am
Location: UK

Post 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.
fletcherjames
Posts: 32
Joined: Mon Mar 13, 2006 3:36 pm
Location: Leesburg, VA
Contact:

Post 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?
Fletcher James
fletcherjames
Posts: 32
Joined: Mon Mar 13, 2006 3:36 pm
Location: Leesburg, VA
Contact:

Post 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.
Fletcher James
fletcherjames
Posts: 32
Joined: Mon Mar 13, 2006 3:36 pm
Location: Leesburg, VA
Contact:

Post 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.
Fletcher James
MichaelNesmith
Posts: 3452
Joined: Thu Dec 22, 2005 7:17 pm
Contact:

Post 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.
Michael Nesmith
Install[b]Aware[/b]
[i]Home of The Next Generation MSI Installer[/i]
Get your free copy today - http://www.installaware.com/
Immelman
Posts: 14
Joined: Thu Jan 11, 2007 4:15 am

Post 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...

Code: Select all

 setup.exe SECRET=TRUE 
Is this possible? And if so can anyone provide an example?
JeffryPaul
Posts: 50
Joined: Fri Mar 02, 2007 6:56 pm

Post 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
ohali
Posts: 61
Joined: Mon Jun 08, 2009 6:41 am

Re: Using custom variables in Command line installs

Post 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.
Obliterator
Posts: 53
Joined: Fri May 01, 2009 11:54 am

Re: Using custom variables in Command line installs

Post 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
alibaba
Posts: 314
Joined: Fri Jun 26, 2009 8:46 am
Location: Thuringia, Germany

Re: Using custom variables in Command line installs

Post 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.
giaviv
Posts: 2039
Joined: Fri Dec 17, 2010 1:39 pm

Re: Using custom variables in Command line installs

Post 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?
Aviv Giladi
InstallAware Software

White Papers (HowTos) - http://www.installaware.com/publication ... papers.htm
Product Guides - http://www.installaware.com/publication ... guides.htm
InstallAware Help -F1 anywhere in the InstallAware IDE
alibaba
Posts: 314
Joined: Fri Jun 26, 2009 8:46 am
Location: Thuringia, Germany

Re: Using custom variables in Command line installs

Post 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!
giaviv
Posts: 2039
Joined: Fri Dec 17, 2010 1:39 pm

Re: Using custom variables in Command line installs

Post 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).
Aviv Giladi
InstallAware Software

White Papers (HowTos) - http://www.installaware.com/publication ... papers.htm
Product Guides - http://www.installaware.com/publication ... guides.htm
InstallAware Help -F1 anywhere in the InstallAware IDE
Post Reply