Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Passing command line options to msi installer created as .NET deployment project

Passing command line options to msi installer created as .NET deployment project

Scheduled Pinned Locked Moved C#
csharpdesignsysadminagentic-aihelp
8 Posts 3 Posters 2 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    StormShearon
    wrote on last edited by
    #1

    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?

    M 1 Reply Last reply
    0
    • S StormShearon

      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?

      M Offline
      M Offline
      mav northwind
      wrote on last edited by
      #2

      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

      S 1 Reply Last reply
      0
      • M mav northwind

        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

        S Offline
        S Offline
        StormShearon
        wrote on last edited by
        #3

        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.

        M 1 Reply Last reply
        0
        • S StormShearon

          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.

          M Offline
          M Offline
          mav northwind
          wrote on last edited by
          #4

          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 to TEST1 and Edit1Value 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 using msiexec /i mysetup.msi TEST1=ThisIsATest then the first textbox will show ThisIsATest instead. Regards, mav

          S O 4 Replies Last reply
          0
          • M mav northwind

            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 to TEST1 and Edit1Value 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 using msiexec /i mysetup.msi TEST1=ThisIsATest then the first textbox will show ThisIsATest instead. Regards, mav

            S Offline
            S Offline
            StormShearon
            wrote on last edited by
            #5

            mav, 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!

            1 Reply Last reply
            0
            • M mav northwind

              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 to TEST1 and Edit1Value 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 using msiexec /i mysetup.msi TEST1=ThisIsATest then the first textbox will show ThisIsATest instead. Regards, mav

              S Offline
              S Offline
              StormShearon
              wrote on last edited by
              #6

              mav, 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!

              1 Reply Last reply
              0
              • M mav northwind

                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 to TEST1 and Edit1Value 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 using msiexec /i mysetup.msi TEST1=ThisIsATest then the first textbox will show ThisIsATest instead. Regards, mav

                S Offline
                S Offline
                StormShearon
                wrote on last edited by
                #7

                mav, 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?

                1 Reply Last reply
                0
                • M mav northwind

                  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 to TEST1 and Edit1Value 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 using msiexec /i mysetup.msi TEST1=ThisIsATest then the first textbox will show ThisIsATest instead. Regards, mav

                  O Offline
                  O Offline
                  OBRon
                  wrote on last edited by
                  #8

                  Mav, 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

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups