Rougellis
Posts: 2
Joined: Wed Sep 12, 2018 10:19 am

How to add and configure command line parameters and functions to the MSI?

Hello,

I've been having a lot of issues attempting to add command line parameters to my MSI.

For the life of me I cannot figure it out.

I am attempting to make it so that I can run my msi with parameter /XYZ at the end of the msi's target.

And example would be I have an MSI called Steam.msi. I then launch Steam.msi with parameter /XYZ, and it additionally launches a bat file saying "hello".

Has anyone done anything like this before? I would be very grateful if someone could weigh on with some advice.
Catalin
Posts: 6586
Joined: Wed Jun 13, 2018 7:49 am

Re: How to add and configure command line parameters and functions to the MSI?

Hello and welcome to our forums,

First of all, thank you for using Advanced Installer.

The Windows Installer technology uses Msiexec.exe for installing MSI and MSP packages.

The usual form of a msiexec command is as it follows:

msiexec.exe <install_option> <path_to_package> [package_parameters]

For more information about this, you can have a look at our "Msiexec.exe Command Line" article.

In what regards the launch process of a "bat" file, you can use our predefined support for "Custom Actions". Custom actions are actions entirely defined by the user. They can be executable files, dynamic linked libraries, Visual Basic scripts or JavaScript files. They can be scheduled at any time during the installation. An installation process consists of two sequences: Installation User Interface Sequence and Installation Execute Sequence.

To launch the .BAT file during the installation process, you can add it as a temporary file in "Files and Folders" page by using the "Add Temporary Files" button from the toolbar. After doing so, you can go to "Custom Actions" page, add a "Launch file" custom action with sequence by using the "Add custom action with sequence" button (located to the right side of the custom action name). After doing so, in the "File to launch" field, you can add your earlier added .BAT file like this:

Code: Select all

[#YourBatFile.bat]
Let me know if that helps!

If there is anything else I can help you with, don't hesitate to contact me and I'll gladly assist.

Kind regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
Rougellis
Posts: 2
Joined: Wed Sep 12, 2018 10:19 am

Re: How to add and configure command line parameters and functions to the MSI?

Thanks for that information.

I'm still having an issue with the launched file. It is still unclear to me how to add a parameter linking that file to be triggered using MSIEXEC. I don't want the file to be launched during installation, I only want it to be launched upon adding a parameter to the command line eg. msiexec /i -launchfile.bat
Catalin
Posts: 6586
Joined: Wed Jun 13, 2018 7:49 am

Re: How to add and configure command line parameters and functions to the MSI?

Hello,

Unfortunately, we do not have a predefined support for this.

You can achieve this through a Windows Installer Property. We will set the property to have the value "No" as default. Then, we will condition the "LaunchFile" custom action to execute only when we set the property to have the value "Yes" from the command line.

To achieve those said above, you can proceed as it follows:

1) Add your .BAT file as a temporary file from the "Files and Folders" page.

2) Now go to "Install Parameters" page.Now click on the "New Property" button from the toolbar and enter the following arguments:

-Name: LAUNCH_BAT

-Value: No

3) Now go to "Custom Actions" page and add a "LaunchFile" custom action with sequence (as I have explained in the previous thread).

4) Under the "Execution Stage Condition", please insert a condition as it follows:

Code: Select all

LAUNCH_BAT = "Yes"
Now, the .BAT file will only be launched if you will set the "LAUNCH_BAT" property to the value "Yes" by using a command line.

In order to achieve that, you can use a command line as it follows:

Code: Select all

msiexec /i "YourMsiFile.msi" LAUNCH_BAT="Yes"
Let me know if that helps!

Regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Building Installers”