Passing command line options to msi installer created as .NET deployment project
-
I could not find any specifc info on the site for the issue I am trying to solve, so I hope someone here has some ideas. I am working with some code created to run test suites and setup scripts. One part of the system installs an agent onto a client PC. I need to find a way to pass command line options to the msi installer UI so that the installation can be run silently. MSI installers have the necessary options to run silently, but so far I have not found a way to pass options from the command line to the UI so that several dialog boxes can be filled without having to get input from a user. Has anyone here run into this and managed to come up with a solution?
-
I could not find any specifc info on the site for the issue I am trying to solve, so I hope someone here has some ideas. I am working with some code created to run test suites and setup scripts. One part of the system installs an agent onto a client PC. I need to find a way to pass command line options to the msi installer UI so that the installation can be run silently. MSI installers have the necessary options to run silently, but so far I have not found a way to pass options from the command line to the UI so that several dialog boxes can be filled without having to get input from a user. Has anyone here run into this and managed to come up with a solution?
Here is the documentation of MSIEXEC's command line options: MSIEXEC on MSDN[^] To give additional values for global properties you have to put them at the end of your call to msiexec in the form:
msiexec /i Sample.msi PROPERTY=VALUE
Regards, mav -
Here is the documentation of MSIEXEC's command line options: MSIEXEC on MSDN[^] To give additional values for global properties you have to put them at the end of your call to msiexec in the form:
msiexec /i Sample.msi PROPERTY=VALUE
Regards, mavmav, I have found the particular documentation you have referenced, and have spent several hours reading it and trying the above syntax. However, it appears that there is no way to link the properties on the UI dialogs and the Property table in the msi database. I have used Orca to look at the database and none of the properties from the UI dialogs are present except for one entry for the each of the edit controls (EDITB1 through EDITB4). Each of these entries are global (all upper case), but do not seem to be connected to anything that actually displays on the UI. They all have a value of 1, but changing that using the above syntax does not do anything - at least that I can determine. I know the syntax works, because I can set things like TARGETDIR and see the change in the dialog when it is displayed.
-
mav, I have found the particular documentation you have referenced, and have spent several hours reading it and trying the above syntax. However, it appears that there is no way to link the properties on the UI dialogs and the Property table in the msi database. I have used Orca to look at the database and none of the properties from the UI dialogs are present except for one entry for the each of the edit controls (EDITB1 through EDITB4). Each of these entries are global (all upper case), but do not seem to be connected to anything that actually displays on the UI. They all have a value of 1, but changing that using the above syntax does not do anything - at least that I can determine. I know the syntax works, because I can set things like TARGETDIR and see the change in the dialog when it is displayed.
I know it can be a bit confusing, but just try the following: In your setup project, add a user dialog with textboxes. Then set
Edit1Property
toTEST1
andEdit1Value
to[TEST1]
. When you build and run your setup, the user dialog will pop up and there will be no entry in the first textbox. If you call your setup usingmsiexec /i mysetup.msi TEST1=ThisIsATest
then the first textbox will showThisIsATest
instead. Regards, mav -
I know it can be a bit confusing, but just try the following: In your setup project, add a user dialog with textboxes. Then set
Edit1Property
toTEST1
andEdit1Value
to[TEST1]
. When you build and run your setup, the user dialog will pop up and there will be no entry in the first textbox. If you call your setup usingmsiexec /i mysetup.msi TEST1=ThisIsATest
then the first textbox will showThisIsATest
instead. Regards, mavmav, Thanks a bunch. The missing piece of the puzzle (which I found nowhere in the docs I read) is this: 'Then set Edit1Property to TEST1 and Edit1Value to [TEST1]' A most critical bit of information and much appreciated!
-
I know it can be a bit confusing, but just try the following: In your setup project, add a user dialog with textboxes. Then set
Edit1Property
toTEST1
andEdit1Value
to[TEST1]
. When you build and run your setup, the user dialog will pop up and there will be no entry in the first textbox. If you call your setup usingmsiexec /i mysetup.msi TEST1=ThisIsATest
then the first textbox will showThisIsATest
instead. Regards, mavmav, Thanks a bunch. The missing piece of the puzzle (which I found nowhere in the docs I read) is this: 'Then set Edit1Property to TEST1 and Edit1Value to [TEST1]' A most critical bit of information and much appreciated!
-
I know it can be a bit confusing, but just try the following: In your setup project, add a user dialog with textboxes. Then set
Edit1Property
toTEST1
andEdit1Value
to[TEST1]
. When you build and run your setup, the user dialog will pop up and there will be no entry in the first textbox. If you call your setup usingmsiexec /i mysetup.msi TEST1=ThisIsATest
then the first textbox will showThisIsATest
instead. Regards, mavmav, I have another question regarding passing in Property values from the command line. The dialog has two properties. One is normally blank and the method you describe works perfectly to set it from the command line during a silent install. The second property has a default value that one might wish to set to a non-default value from the command line during a silent install. Now, it seems that one must somehow use the MsiSetProperty method in a custom action that checks to see if the passed in value of the property is a null string, and if so, sets it to the default value. It also seems that one would have to write a custom dll to do this, and link it properly in the custom actions editor in the deployment project. Is this the correct way to accomplish this or is there something simpler?
-
I know it can be a bit confusing, but just try the following: In your setup project, add a user dialog with textboxes. Then set
Edit1Property
toTEST1
andEdit1Value
to[TEST1]
. When you build and run your setup, the user dialog will pop up and there will be no entry in the first textbox. If you call your setup usingmsiexec /i mysetup.msi TEST1=ThisIsATest
then the first textbox will showThisIsATest
instead. Regards, mavMav, thanks for sharing this information - it was very helpful in understanding how to pass a command line parameter to the Installer and see that value show up on a text field. I have a question though, how can I programatically detect that I didn't get a command line parameter and populate those text fields another way? Perhaps I read the registry or a text file. I want to handle the situation where I prompted a user for something during the first install, and subsequent installs I show them the previous value and allow them to change it - unless I get a command line argument - which trumps this logic. Thanks again for sharing the information though...very helpful. -Ron