Freigeben über


Windows Installer: Installing for Everyone in a Silent Install

[updated: cleaned up links]
I got bitten last week by a subtlety in the way Windows Installer packages generated by Visual Studio 2003 handle installing for everyone rather than the default "Just Me" when being run as a silent install. Maybe less a subtlety in the installer than a gap in my understanding of the installer's workings. At any rate; since I had a more difficult time than I thought I would finding the right answer I figured I'd post it here so Googlers everywhere can find it easily.

Creating an installer package from within Visual Studio 2003 is pretty simple and straightforward. For many simple deployment scenarios creating a new project of type "setup project" and adding the primary output of another project in your solution gets you most of the way there. Visual Studio does a good job of exposing the properties of the underlying MSI database as design-time properties.

One common scenario that isn't covered by Visual Studio 2003 is setting the default value of the "Install for . . ." option in the setup routine from Visual Studio. The default value is "Install for Just Me," and oftentimes you'll want/need to default to "Install for Everyone" instead. This is a per-machine installation rather than a per-user installation in Windows Installer parlance.

In order to accomplish this you need to open the MSI package Visual Studio generates for you using a tool like Orca (part of the Windows Installer SDK, which is part of the Platform SDK. Get it at https://www.microsoft.com/msdownload/platformsdk/sdkupdate) and edit the database manually.

To default to a per-machine installation you simply change the value of the FolderForm_AllUsers property (in the properties table) from "ME" to "ALL." This is all you need to do in scenarios where you are presenting the user with a UI in that the value of the "Install for" radio button will now default to "All Users" which is what you want.

The problem I hit was that this doesn't cover the cases where no (or a limited) UI is displayed to the user. In my case our Operations team was deploying my app to a cluster of servers using a remote shell to execute msiexec with the /q option (no UI). I'd thought the underlying default property would be passed through in this case regardless of the presence of the UI, but I was wrong. To cover this case you need to add an additional property to the MSI.

To ensure that the installation defaults to Everyone in a silent install, create a new property in the properties table named "ALLUSERS" and set its value to "2" By default this property doesn't exist in the Visual Studio generated MSI, so it's value is unset, which indicates a per-user installation. If only users with Administrative privileges should be able to install your package you can set this property to "1" in which case the installation will fail if the installing user doesn't have admin rights. Setting "ALLUSERS" to "2" will attempt to do a per-user install if the per-machine install fails because the user doesn't have administrative privilleges.

If you've set this property because you don't want users to be able to install for "Just Me" (as was my case) you'll want to remove the option of setting this property in the UI. You can also either get rid of the dialog that offers the choice altogether or hide it if you don't want to offer the choice to your users.

In my case I hid them by dropping all the rows for the "AllUsersRadioGroup" and "AllUsersText" actions (there are 2 actions per control for these -- a hide and a show. Drop them all) from the ControlCondition table. I then set the attributes for the "AllUsersRadioGroup" and "AllUsersText" controls in the Control table to "2".

That was all it took, and I could stop blocking the release of an entire suite of projects to our production environment ;-)

More information on using Orca can be found here.

More information on per-user and per-machine installs can be found here.

Comments

  • Anonymous
    September 09, 2004
    While you're at it, you might as well use Orca to export the Property and ControlCondition tables. This will allow you to simply import the table after subsequent MSI builds in VStudio instead of manually performing the edits over and over again.
  • Anonymous
    September 30, 2004
    Thanks for the information. How do I set "I then set the attributes for the "AllUsersRadioGroup" and "AllUsersText" controls in the Control table to "2". "


  • Anonymous
    September 30, 2004
    Nirupama: you'll need to edit the MSI using a tool like Orca (see http://support.microsoft.com/default.aspx?scid=kb;EN-US;255905).

    Open the Control table, and sort by the Control column in the view on that table. Find the "AllUsersRadioGroup" and "AllUsersText" controls (they're both in the "FolderForm" dialog), and change the values in the Attribute columns to "2"

    Once you've saved the MSI, follow Nicole's suggestion so you don't need to keep doing this over and over again like I was ;-)
  • Anonymous
    September 30, 2004
    Thanks Mollman. I did it. But, where should I export the tables to. What is the Output Drirectory I should select in order to streamline this.
  • Anonymous
    September 30, 2004
    Export to any directory you like -- you only need to be able to find the exported files again when you want to re-import them.

    I usually export to the same directory the MSI is in.
  • Anonymous
    September 30, 2004
    The comment has been removed