Search code examples
wixinstallationwindows-installershortcut

Create shortcut to desktop using WiX


How do I create a shortcut on the desktop from a wix setup project?


Solution

  • The shortcut is a non-advertised one. Remember to put the component in your feature tag.

    <Directory Id="TARGETDIR" Name="SourceDir">
        <Directory Id="DesktopFolder" Name="Desktop">
            <Component Id="ApplicationShortcutDesktop" Guid="*">
                <Shortcut Id="ApplicationDesktopShortcut"
                    Name="Text under your icon"
                    Description="Comment field in your shortcut"
                    Target="[MYAPPDIRPROPERTY]MyApp.exe"
                    WorkingDirectory="MYAPPDIRPROPERTY"/>
                <RemoveFolder Id="DesktopFolder" On="uninstall"/>
                <RegistryValue
                    Root="HKCU"
                    Key="Software\MyCompany\MyApplicationName"
                    Name="installed"
                    Type="integer"
                    Value="1"
                    KeyPath="yes"/>
            </Component>
        </Directory>
    
        <Directory Id="ProgramFilesFolder" Name="PFiles">
            <Directory Id="MyCompany" Name="MyCompany">
                <Directory Id="MYAPPDIRPROPERTY" Name="MyAppName">
                    <!-- main installation files -->
                </Directory>
            </Directory>
        </Directory>
    </Directory>