Question

I'm creating an installer msi file using the Windows Installer XML toolkit. When installing the created msi file, a shortcut placed under the ProgramMenuFolder folder results in a shortcut for the Administrator user only. How do I let the installer create a shortcut under the All Users profile, so that everyone on the machine has the shortcut?

Was it helpful?

Solution

Stuart Preston's blog has a good description of how to do this:

Installing a shortcut for "All Users" (via Wayback Machine)

Edit:

The synopsys is:

In your .wxs file, include the following:

<Property Id="ALLUSERS"><![CDATA[2]]></Property>

This will preset a property which mimics the behaviour of selecting the "All Users" rather than "Just Me" for your installation. You'll need a directory structure similar to the following too:

<Directory Id='ProgramMenuFolder' Name='PMenu' LongName='Programs'>
<Directory Id='MyProductShortcutDir' Name='MyPMenu' LongName='MyProduct' />
</Directory>

Finally, your shortcut should be within a "File" element, as follows:

<File Id="MyProduct.File0" LongName="MyProduct.exe" Name="MYPROD_1.EXE" src="c:\MyProductSourceFolder\MyProduct.exe" >
<Shortcut Id="MyProduct.Shortcut" Directory="MyProductShortcutDir" Name="MPSCUT" LongName="My Product Shortcut" /> 
</File>

OTHER TIPS

In the Package element, add an InstallScope attribute like this:

InstallScope='perMachine'

Based on the SampleFirst.wxs in the WIX Tutorial http://www.tramontana.co.hu/wix/lesson1.php there were two parts that I changed.

First, add the property ALLUERS = 1 "". That installs the shortcut to the all users profile as others have noted.

Second, change the root for the registry value for Component 'ProgramMenuDir' to HKMU. The installer will decide if it should use HKLM (Local Machine) or HKCU (Current User) at install time, based on the on the ALLUSERS property.

You should then be able to add dialogs to modify the ALLUSERS property, with the registry root changing accordingly.

<?xml version="1.0" encoding="utf-8"?>
<!-- Original Source available at "http://www.tramontana.co.hu/wix/download.php?file=samples/samplefirst.zip&type=application/zip" 
  This version has been modified for a local machine install (all users) vs a user install-->
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
    <Product Name="Foobar 1.0" Id="YOURGUID-CD32-4B20-BB4F-58A5C3B21A7C" UpgradeCode="YOURGUID-EDCE-42A2-9DA2-59FB08AC4FA6" Language="1033" Codepage="1252" Version="1.0.0" Manufacturer="Acme Ltd.">
        <Package Id="*" Keywords="Installer" Description="Acme's Foobar 1.0 Installer" Comments="Foobar is a registered trademark of Acme Ltd." Manufacturer="Acme Ltd." InstallerVersion="100" Languages="1033" Compressed="yes" SummaryCodepage="1252" />
        <Media Id="1" Cabinet="Sample.cab" EmbedCab="yes" DiskPrompt="CD-ROM #1" />
        <Property Id="DiskPrompt" Value="Acme's Foobar 1.0 Installation [1]" />
        <Property Id="ALLUSERS" Value="1" />
        <Directory Id="TARGETDIR" Name="SourceDir">
            <Directory Id="ProgramFilesFolder" Name="PFiles">
                <Directory Id="Acme" Name="Acme">
                    <Directory Id="INSTALLDIR" Name="Foobar 1.0">
                        <Component Id="MainExecutable" Guid="YOURGUID-2191-4A98-806B-2554B0DD8FC3">
                            <File Id="FoobarEXE" Name="FoobarAppl10.exe" DiskId="1" Source="FoobarAppl10.exe" KeyPath="yes">
                                <Shortcut Id="startmenuFoobar10" Directory="ProgramMenuDir" Name="Foobar 1.0" WorkingDirectory="INSTALLDIR" Icon="Foobar10.exe" IconIndex="0" Advertise="yes" />
                                <Shortcut Id="desktopFoobar10" Directory="DesktopFolder" Name="Foobar 1.0" WorkingDirectory="INSTALLDIR" Icon="Foobar10.exe" IconIndex="0" Advertise="yes" />
                            </File>
                        </Component>
                        <Component Id="HelperLibrary" Guid="YOURGUID-7BA7-4BD1-90B9-C0DFC21674B1">
                            <File Id="HelperDLL" Name="Helper.dll" DiskId="1" Source="Helper.dll" KeyPath="yes" />
                        </Component>
                        <Component Id="Manual" Guid="YOURGUID-F60A-48D6-83FD-44ED01AA579A">
                            <File Id="Manual" Name="Manual.pdf" DiskId="1" Source="Manual.pdf" KeyPath="yes">
                                <Shortcut Id="startmenuManual" Directory="ProgramMenuDir" Name="Instruction Manual" Advertise="yes" />
                            </File>
                        </Component>
                    </Directory>
                </Directory>
            </Directory>
            <Directory Id="ProgramMenuFolder" Name="Programs">
                <Directory Id="ProgramMenuDir" Name="Foobar 1.0">
                    <Component Id="ProgramMenuDir" Guid="YOURGUID-2D4F-443F-9ADA-563DB3C1581F">
                        <RemoveFolder Id="ProgramMenuDir" On="uninstall" />
                        <RegistryValue Root="HKMU" Key="Software\[Manufacturer]\[ProductName]" Type="string" Value="" KeyPath="yes" />
                    </Component>
                </Directory>
            </Directory>
            <Directory Id="DesktopFolder" Name="Desktop" />
        </Directory>
        <Feature Id="Complete" Level="1">
            <ComponentRef Id="MainExecutable" />
            <ComponentRef Id="HelperLibrary" />
            <ComponentRef Id="Manual" />
            <ComponentRef Id="ProgramMenuDir" />
        </Feature>
        <Icon Id="Foobar10.exe" SourceFile="FoobarAppl10.exe" />
        <UI />
    </Product>
</Wix>

Bob Arnson has a blog entry that covers how to set User vs. Machine in Wix.
The quick answer is to set the Package element's InstallScope attribute to "perMachine".

Simple define ALLUSERS=1 to force a per-machine installation.

  <Property Id="ALLUSERS"><![CDATA[1]]></Property>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top