Practical guide

WiX shortcuts and file associations: WiX 3 and WiX 5 examples

A shortcut launches an installed application. A file association tells Windows which application can open a document type. This guide connects both to one executable and shows how to inspect the same authoring in WixPie.

1. Start with a working application

Use a copy of an application you own and can test. The example calls it MyApp.exe and registers the uncommon .wpxsample extension. Choose identifiers, a product name and an extension for your real product before adapting the source.

Keep the WiX family consistent: WiX 3 uses Product and Directory; WiX 5 uses Package and StandardDirectory in the v4 XML namespace. Download only the matching source. The commands select x86; adapt the architecture and components together for a real 64-bit application.

Complete shortcut and file-association sources

Choose WiX 3 or WiX 5 and save its Shortcuts.wxs beside your own MyApp.exe. The executable is not included: it must run independently and accept a document path as its first argument. These are 32-bit, per-machine MSI sources, compiled with both toolsets using a small test executable. Add any dependencies your real application needs before shipping the package.

WiX 5 · Shortcuts.wxs
Download Shortcuts.wxs (WiX 5)
<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
  <Package Name="WixPie Association Sample" Language="1033" Version="1.0.0"
           Manufacturer="Example Company" UpgradeCode="69C94E05-1F80-4127-B5E6-9B0260D7E462"
           Scope="perMachine">
    <MajorUpgrade DowngradeErrorMessage="A newer version is already installed." />
    <MediaTemplate EmbedCab="yes" />
    <StandardDirectory Id="ProgramFilesFolder">
      <Directory Id="INSTALLFOLDER" Name="WixPie Association Sample">
        <Component Id="AppComponent" Guid="*">
          <File Id="AppFile" Source="MyApp.exe" KeyPath="yes">
            <Shortcut Id="AppShortcut" Directory="AppMenuFolder" Name="WixPie Association Sample"
                      Advertise="yes" WorkingDirectory="INSTALLFOLDER" />
          </File>
          <ProgId Id="Example.WixPieSample.Document" Description="WixPie sample document" Advertise="no">
            <Extension Id="wpxsample" ContentType="application/x-wpxsample" Advertise="no">
              <Verb Id="open" Command="Open" TargetFile="AppFile" Argument="&quot;%1&quot;" />
            </Extension>
          </ProgId>
          <RemoveFolder Id="RemoveAppMenuFolder" Directory="AppMenuFolder" On="uninstall" />
        </Component>
      </Directory>
    </StandardDirectory>
    <StandardDirectory Id="ProgramMenuFolder">
      <Directory Id="AppMenuFolder" Name="WixPie Association Sample" />
    </StandardDirectory>
    <Feature Id="MainFeature" Title="WixPie Association Sample" Level="1">
      <ComponentRef Id="AppComponent" />
    </Feature>
  </Package>
</Wix>

Build from the sample folder

wix build Shortcuts.wxs -arch x86 -o AssociationSample.msi
WiX 3 · Shortcuts.wxs
Download Shortcuts.wxs (WiX 3)
<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
  <Product Id="*" Name="WixPie Association Sample" Language="1033" Version="1.0.0"
           Manufacturer="Example Company" UpgradeCode="69C94E05-1F80-4127-B5E6-9B0260D7E462">
    <Package InstallerVersion="500" Compressed="yes" InstallScope="perMachine" />
    <MajorUpgrade DowngradeErrorMessage="A newer version is already installed." />
    <MediaTemplate EmbedCab="yes" />
    <Directory Id="TARGETDIR" Name="SourceDir">
      <Directory Id="ProgramFilesFolder">
        <Directory Id="INSTALLFOLDER" Name="WixPie Association Sample">
          <Component Id="AppComponent" Guid="*">
            <File Id="AppFile" Source="MyApp.exe" KeyPath="yes">
              <Shortcut Id="AppShortcut" Directory="AppMenuFolder" Name="WixPie Association Sample"
                        Advertise="yes" WorkingDirectory="INSTALLFOLDER" />
            </File>
            <ProgId Id="Example.WixPieSample.Document" Description="WixPie sample document" Advertise="no">
              <Extension Id="wpxsample" ContentType="application/x-wpxsample" Advertise="no">
                <Verb Id="open" Command="Open" TargetFile="AppFile" Argument="&quot;%1&quot;" />
              </Extension>
            </ProgId>
            <RemoveFolder Id="RemoveAppMenuFolder" Directory="AppMenuFolder" On="uninstall" />
          </Component>
        </Directory>
      </Directory>
      <Directory Id="ProgramMenuFolder">
        <Directory Id="AppMenuFolder" Name="WixPie Association Sample" />
      </Directory>
    </Directory>
    <Feature Id="MainFeature" Title="WixPie Association Sample" Level="1">
      <ComponentRef Id="AppComponent" />
    </Feature>
  </Product>
</Wix>

Build from the sample folder

candle.exe -arch x86 Shortcuts.wxs
light.exe -out AssociationSample.msi Shortcuts.wixobj

The UpgradeCode identifies this sample's upgrade family. Generate your own UpgradeCode when creating a different real product, then keep it stable for later versions of that product. Keep authored component and file IDs stable when maintaining a released installer.

2. Connect the Start Menu shortcut to the installed file

AppFile installs MyApp.exe under INSTALLFOLDER. Its nested Shortcut points to AppMenuFolder under ProgramMenuFolder. Name is the Start Menu label; WorkingDirectory identifies the application directory.

Advertise="yes" makes Windows Installer resolve the shortcut target through the component and feature instead of a development path. MainFeature references AppComponent. RemoveFolder removes the product-specific menu directory on uninstall when it is empty. Keep component and file IDs stable when maintaining a released product.

3. Register a document type and quote its path

ProgId identifies the document class. Extension uses wpxsample without a leading dot. The open Verb targets AppFile. XML-escaped quotes around %1 preserve a document path containing spaces as one command-line argument. Your application must actually implement opening that argument.

This file association is non-advertised. Registration does not guarantee that Windows makes your application the current default. User choices and Windows default-app controls still apply. Do not overwrite protected UserChoice settings to force a default.

4. Inspect the source in WixPie

Open Shortcuts.wxs through File → Open files… and select a matching WiX 3 or WiX 5 template. Inspect the properties exposed by that template, then review the XML preview. Available visual operations depend on the selected template.

For a local build, connect the Local Agent and extension and preserve the payload and source paths. Keep the original source in version control. Review changes to Shortcut, ProgId, Extension, Verb and ComponentRef before replacing an existing installer definition.

5. Check installation, opening and removal

Build with the matching toolset, then install in Windows Sandbox or a disposable Windows test machine. This per-machine package may require administrator approval. Launch the Start Menu shortcut and confirm it starts the installed application.

Create a document with spaces in its path, such as Documents\Sample folder\first file.wpxsample. Select your application through Open with or Windows default-app settings if necessary. Confirm it receives the complete path. Uninstall and check removal of the shortcut, owned file-association entries and application payload.

Compiler success validates MSI authoring. It does not prove your application handles documents correctly or that upgrades preserve user preferences. Test upgrades and removal with your actual application before distribution.

Try the workflow in WixPie

Open the browser editor to explore a compatible template. For local files and MSI builds, follow the Local Agent and extension setup on the Downloads page.

WiX reference documentation