Cannot create Desktop shortcut

Posted by Pantelis on Stack Overflow See other posts from Stack Overflow or by Pantelis
Published on 2014-08-23T16:16:34Z Indexed on 2014/08/23 16:20 UTC
Read the original article Hit count: 240

I have a WiX project and I want to automatically create a ProgramMenu and Desktop shortcut. I've tried the following but the Desktop shortcut is not created. The ProgramMenu shortcut works great.

<Product Id="*" Name="Application Name" Language="1033" Version="1.0.0.0" Manufacturer="Company Name">
    <Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine"  Description="A description" Comments="Some Comments" />
    <MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
    <MediaTemplate  EmbedCab="yes"/>
    <!-- Minimal UI -->
    <UIRef Id="WixUI_Minimal"/>

    <!-- Adding the referenced components -->
    <Feature Id="Complete" Title="inStorHDRadio Complete" Level="1">
        <ComponentGroupRef Id="InstallationComponents" />            
        <ComponentRef Id="ApplicationProgramsMenuShortcut"/>
        <ComponentRef Id="ApplicationDesktopShortcut"/>      
    </Feature>
</Product>

<Fragment>
    <Directory Id="TARGETDIR" Name="SourceDir">
        <!-- Installation Folder -->
        <Directory Id="ProgramFilesFolder">
            <Directory Id="CompanyFolder" Name="CompanyName">
                <Directory Id="InstallationFolder" Name="ApplicationName"/>
            </Directory>
        </Directory>

        <!-- Programs Menu Shortcut Folder -->
        <Directory Id="ProgramMenuFolder" Name="ProgramsMenu">
            <Directory Id="ProgramsMenuCompanyFolder" Name="CompanyName">
                <Directory Id="ProgramsMenuShortcutFolder" Name="ApplicationName"/>
            </Directory>
        </Directory>

        <!-- Desktop Shortcut Folder -->
        <Directory Id="DesktopShortcutFolder" Name="Desktop"/>
    </Directory>
</Fragment>

<!-- Compoments -->
<Fragment>
    <ComponentGroup Id="inStorHDRadioComponents" Directory="InstallationFolder">
        <!-- All application components in Program Files -->
    </ComponentGroup>

    <!-- SHORTCUTS -->
    <!--ProgramsMenu-->
    <DirectoryRef Id='ProgramsMenuShortcutFolder'>
        <Component Id='ApplicationProgramsMenuShortcut'>
            <RemoveFolder Id='RemoveProgramsMenuShortcutFolder' Directory='ProgramsMenuShortcutFolder' On='uninstall' />
            <RemoveFolder Id='RemoveProgramsMenuCompanyFolder' Directory='ProgramsMenuCompanyFolder' On='uninstall' />           
            <Shortcut
                Id='ApplicationProgramsMenuShortcut'
                Name='Company Name'
                Target='[#Application.exe]'            
                WorkingDirectory='InstallationFolder' 
                Icon='application.ico' />
            <RegistryValue
                Name='RegistryValueProgramMenuShortcut'
                Root='HKCU'
                Key='Software\Microsoft\[Manufacturer]\[ProductName]'            
                Type='integer'
                Value='1' />
        </Component>      
    </DirectoryRef>

    <!--Desktop-->
    <DirectoryRef Id='DesktopShortcutFolder'>
        <Component Id='ApplicationDesktopShortcut'>
            <RemoveFolder Id='RemoveDesktopShortcutFolder' Directory='DesktopShortcutFolder' On='uninstall'/>
            <Shortcut
                Id='ApplicationDesktopShortcut'
                Name='Application Name'
                Target='[#Bootstrapper.exe]'            
                WorkingDirectory='InstallationFolder' 
                Directory='DesktopShortcutFolder'            
                Advertise='no'
                Icon='application.ico'/>
            <RegistryValue
                Name='RegistryValDesktopShortcut'
                Root='HKCU'
                Key='Software\[Manufacturer]\[ProductName]'
                KeyPath='yes'
                Type='integer'
                Value='1' />           
        </Component>      
    </DirectoryRef>
</Fragment>

<Fragment>
    <Icon Id="application.ico" SourceFile="Files\application.ico" />
    <Icon Id="programs.ico" SourceFile="Files\programs.ico"/>
    <Property Id="ARPPRODUCTICON" Value="programs.ico" />
    <Property Id="ARPHELPLINK" Value="http://www.company.com" />
</Fragment>

Whats wrong with the code? The ProgramMenu shortcut is working perfectly fine, but the desktop one is not getting created.

© Stack Overflow or respective owner

Related posts about wix

Related posts about windows-installer