Capture/Pass Variable Data Via Command Line Switch/Parameter

Got a problem you cannot solve? Try here.
SebSpiers
Posts: 38
Joined: Tue Dec 20, 2016 7:14 am
Location: Tewkesbury, UK

Capture/Pass Variable Data Via Command Line Switch/Parameter

Postby SebSpiers » Thu Jan 19, 2017 10:15 am

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?
I'm not a developer, I just want to install things...

FrancescoT
Site Admin
Posts: 5360
Joined: Sun Aug 22, 2010 4:28 am

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

Postby FrancescoT » Thu Jan 19, 2017 2:41 pm

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
Francesco Toscano
InstallAware Software

White Papers (HowTos) - http://www.installaware.com/publication ... papers.htm
Publications - http://www.installaware.com/publications-review.htm
InstallAware Help -F1 anywhere in the InstallAware IDE

SebSpiers
Posts: 38
Joined: Tue Dec 20, 2016 7:14 am
Location: Tewkesbury, UK

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

Postby SebSpiers » Thu Jan 26, 2017 9:42 am

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?
I'm not a developer, I just want to install things...

FrancescoT
Site Admin
Posts: 5360
Joined: Sun Aug 22, 2010 4:28 am

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

Postby FrancescoT » Thu Jan 26, 2017 1:08 pm

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
Francesco Toscano
InstallAware Software

White Papers (HowTos) - http://www.installaware.com/publication ... papers.htm
Publications - http://www.installaware.com/publications-review.htm
InstallAware Help -F1 anywhere in the InstallAware IDE

SebSpiers
Posts: 38
Joined: Tue Dec 20, 2016 7:14 am
Location: Tewkesbury, UK

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

Postby SebSpiers » Fri Jan 27, 2017 4:25 am

Ah OK, I'll give that a whirl!

Thanks
I'm not a developer, I just want to install things...

SebSpiers
Posts: 38
Joined: Tue Dec 20, 2016 7:14 am
Location: Tewkesbury, UK

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

Postby SebSpiers » Fri Jan 27, 2017 5:00 am

IT WORKED! :D
I'm not a developer, I just want to install things...

NeeeeB
Posts: 12
Joined: Mon May 17, 2021 2:32 am

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

Postby NeeeeB » Wed May 19, 2021 7:30 am

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

NeeeeB
Posts: 12
Joined: Mon May 17, 2021 2:32 am

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

Postby NeeeeB » Wed May 19, 2021 9:03 am

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:

FrancescoT
Site Admin
Posts: 5360
Joined: Sun Aug 22, 2010 4:28 am

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

Postby FrancescoT » Wed May 19, 2021 12:49 pm

Happy you solved!
Francesco Toscano
InstallAware Software

White Papers (HowTos) - http://www.installaware.com/publication ... papers.htm
Publications - http://www.installaware.com/publications-review.htm
InstallAware Help -F1 anywhere in the InstallAware IDE


Return to “Technical Support”

Who is online

Users browsing this forum: Google [Bot] and 50 guests