Page 1 of 1

Capture/Pass Variable Data Via Command Line Switch/Parameter

Posted: Thu Jan 19, 2017 10:15 am
by SebSpiers
Hi,

Is it possible to pass data via a command line parameter?

My installer requires the end user to supply some data, and whilst I have created some custome dialog pages to capture this, for some implementations I would like the deployment to be possible using the MSI and a /silent command line switch.

This means that I either need to specify some default values within the installer which will need to be modified post installation, or allow the end users to supply data via command line parameters, eg.

Code: Select all

setup.msi /location C:\Whatever /server 172.0.0.1


Is this possible?

Re: Capture/Pass Variable Data Via Command Line Switch/Parameter

Posted: Thu Jan 19, 2017 2:41 pm
by FrancescoT
Dear SebSpiers,

of course you can, but with a MSI package, you need to pass all your variables and values within the CMDLINE public MSI property.

For example;

msiexec.exe /i "C:\mypackage.msi" CMDLINE="MY_FIRST_PROPERTY=TRUE MY_SECOND_PROPERTY=FALSE"

Hope this helps you.

Regards

Re: Capture/Pass Variable Data Via Command Line Switch/Parameter

Posted: Thu Jan 26, 2017 9:42 am
by SebSpiers
So, just so I understand, MY_FIRST_PROPERTY would be a variable?
Do I need to define this before? If I am Setting a Variable, will it not make it null?
How do I capture the data within my MSI code?

Re: Capture/Pass Variable Data Via Command Line Switch/Parameter

Posted: Thu Jan 26, 2017 1:08 pm
by FrancescoT
Dear SebSpiers,

simply assign your variables to Themselves at the very beginning of your script.
https://www.installaware.com/forums/viewtopic.php?f=2&t=4899

Example;

- Set Variable MY_VARIABLE to $MY_VARIABLE$

Hope this helps you.

Regards

Re: Capture/Pass Variable Data Via Command Line Switch/Parameter

Posted: Fri Jan 27, 2017 4:25 am
by SebSpiers
Ah OK, I'll give that a whirl!

Thanks

Re: Capture/Pass Variable Data Via Command Line Switch/Parameter

Posted: Fri Jan 27, 2017 5:00 am
by SebSpiers
IT WORKED! :D

Re: Capture/Pass Variable Data Via Command Line Switch/Parameter

Posted: Wed May 19, 2021 7:30 am
by NeeeeB
I'm sorry to dig up this old thread, but I have the exact same request and it doesn't work for me...
this is how I try to run my .msi :

.\Diane.msi CMDLINE="ALIAS=alias DRIVERID=driverId DATABASE=database USER=user SERVER=server"

when I use this syntax, all I get is the .msi commandline help window showing, meaning there is a problem in the syntax (I suspect it is the " " that is not supported)

If i run the command this way :

.\Diane.msi CMDLINE=ALIAS=alias DRIVERID=driverId DATABASE=database USER=user SERVER=server

Of course it doesn't work too...

My variables are declared as this in the MSICODE at the very beginning of the script:
Image
share pictures iphone

and later on, I do this :
Image

PS: running the Diane.exe (meaning no msi) with these arguments work like a charm.
.\Diane.exe ALIAS=alias DRIVERID=driverId DATABASE=database USER=user SERVER=server

But I desperatly need the .msi...

Re: Capture/Pass Variable Data Via Command Line Switch/Parameter

Posted: Wed May 19, 2021 9:03 am
by NeeeeB
Note for later users :

Works with cmd.exe, does not work with PowerShell...I think it might be related to the double quotes but was enough in rage to have spent half a day on that stupid thing not to check what the correct syntax is with PowerShell... :evil:

Re: Capture/Pass Variable Data Via Command Line Switch/Parameter

Posted: Wed May 19, 2021 12:49 pm
by FrancescoT
Happy you solved!