Page 1 of 1
Commandline parameters
Posted: Thu Sep 01, 2005 7:51 am
by zchris
I can pass commandline parameters to my setup by running:
Code: Select all
setup.exe PARAM1=value PARAM2=value
In my script I want to use PARAM1 if it was specified, otherwise I want to use my own default.
First I need to define the variable in my script:
(I set it to $PARAM1$ so that I don't loose the value from the command line)
Now PARAM1 either contains the value that was specified on the command line or the string "$PARAM1$".
Next I want to set my default:
Code: Select all
If Variable PARAM1 equals $PARAM1$
Set Variable PARAM1 to my default value
end
This will obviously not work as it is always true - but how do I specify "$PARAM1$" (
the string, not the variable) in the if command? Is the some escape character for the $?
Thanks!
Re: Commandline parameters
Posted: Thu Sep 01, 2005 8:34 am
by jimo
zchris wrote:I can pass commandline parameters to my setup by running:
Code: Select all
setup.exe PARAM1=value PARAM2=value
In my script I want to use PARAM1 if it was specified, otherwise I want to use my own default.
First I need to define the variable in my script:
(I set it to $PARAM1$ so that I don't loose the value from the command line)
Now PARAM1 either contains the value that was specified on the command line or the string "$PARAM1$".
Next I want to set my default:
Code: Select all
If Variable PARAM1 equals $PARAM1$
Set Variable PARAM1 to my default value
end
This will obviously not work as it is always true - but how do I specify "$PARAM1$" (
the string, not the variable) in the if command? Is the some escape character for the $?
Thanks!
Why not put the "If statement" as the first line in the script so you get the command line right away and act upon it. I don't think you need the extra lines of code, or maybe something like
Code: Select all
IF Variable PARAM1 equals
Set Variable CL_PARAM1 to my default value
else
Set Variable CL_PARAM1 to $PARAM1$
end
Posted: Thu Sep 01, 2005 8:44 am
by sinan
Command line parameter handling is now easier, in InstallAware 2005 Second Edition.
First, initialize the variable in the script to its default value, using Set Variable. Then, modify the variable as you see fit in the script.
Now, if that variable is specified on the command line, its value will be locked throughout the script execution. All Set Variable commands on that variable will return without actually updating the variable.
Re: Commandline parameters
Posted: Fri Sep 02, 2005 2:07 am
by zchris
jimo wrote:Why not put the "If statement" as the first line in the script so you get the command line right away and act upon it. I don't think you need the extra lines of code, or maybe something like
Code: Select all
IF Variable PARAM1 equals
Set Variable CL_PARAM1 to my default value
else
Set Variable CL_PARAM1 to $PARAM1$
end
That would be nice - however InstallAware won't let you use a variable unless you declare it first by using a set command. Your code would produce a compile time error.
Posted: Fri Sep 02, 2005 2:20 am
by zchris
sinan wrote:Command line parameter handling is now easier, in InstallAware 2005 Second Edition.
First, initialize the variable in the script to its default value, using Set Variable. Then, modify the variable as you see fit in the script.
Now, if that variable is specified on the command line, its value will be locked throughout the script execution. All Set Variable commands on that variable will return without actually updating the variable.
I am using Install
Aware 2005 Second Edition - however it does not work as you say. I just tried it and all variables can be changed even if they are specified on the command line.
Actually I would not want it to work the way you described it. I have a "Set Variable ALLUSERS to TRUE" in my code. A commandline parameter ALLUSERS=FALSE could simply override that value even though the setup expects to be installed for all users.
OK, now how do I test if the PARAM1 contains the string "$PARAM1$"?
List index out of bounds(0)
Posted: Fri Sep 02, 2005 2:48 am
by zchris
I stumbled across a bug when I tried to get this code to work:
Code: Select all
Set Variable D to $
Set Variable PARAM1 to $PARAM1$
If Variable PARAM1 equals $D$PARAM1$D$
Set Variable PARAM1 to my default value
end
InstallAware will no longer open my project - it gives me the error "List index out of bounds(0)". After that it will show the error even if you just start InstallAware from the start menu.
I was able to get things working again by editing the mia with notepad.
Posted: Fri Sep 02, 2005 5:02 am
by sinan
I forgot to mention, the variables are locked only when running silent installations. Variable values are not locked when not running silent installations (the /s command line parameter) as this would be quite confusing.
Does this help?
Posted: Mon Sep 05, 2005 2:42 am
by zchris
sinan wrote:I forgot to mention, the variables are locked only when running silent installations. Variable values are not locked when not running silent installations (the /s command line parameter) as this would be quite confusing.
OK. I still have the same problem. I am running a normal (not silent) setup and I want to either read in the command line paramters or use my own defaults.
Thanks.
Posted: Mon Sep 05, 2005 4:03 am
by sinan
In that case, I recommend you access the command line directly. Just read the value of the pre-defined variable CMDLINE, and search for the text you are looking for using the Parse String command.
Posted: Mon Sep 05, 2005 6:17 am
by zchris
OK, thanks. I will take a look at that.
Do you know if there is a (possibly undocumented) variable that contains the $ character (like $NEWLINE$ that contains a newline)?
I want to assign it to a variable and
does not work.
Thanks!
Posted: Mon Sep 05, 2005 8:11 pm
by sinan
No, there is none - however the variable assignment may fail because the $ is a reserved symbol.