Create a Desktop Shortcut to an existing FOLDER using WiX

Posted by Sach on Stack Overflow See other posts from Stack Overflow or by Sach
Published on 2010-04-22T08:54:19Z Indexed on 2010/05/01 22:57 UTC
Read the original article Hit count: 466

I have the need to create a Desktop Shortcut to an existing FOLDER (NOT to a file) using Wix. To elaborate more, my installer program has a CustomAction program written using C# associated with it. This CustomAction program creates a folder named "BSS" of which the path is selected by user.

C:\ProgramData\MT\BSS

Now I need to place a Desktop Shortcut to this folder using WiX. However, I encounter a problem since this folder does not have a folder structure within WiX. The closest code I could find was the following.

<Directory Id="DesktopFolder" Name="Desktop"/>
  <Directory Id="CommonAppDataFolder" Name="ProgramDataFolder"/>
  <Component Id="ComponentBSStrageShortcut" Guid="{8436995c-2e76-4030-b92d-c6b4bc243c43}">
    <Shortcut Id="ShortcutBSStrageShortcut"
              Directory="DesktopFolder"
              WorkingDirectory="APPLICATIONFOLDER"
              Target="[CommonAppDataFolder]/MTK/BSStrage"
              Name="BSStrage"
              Show="normal"/>
    <RegistryValue Action="write"
                   Key="SOFTWARE/MTK/BackStreet"
                   Root="HKCU"
                   Type="string"
                   KeyPath="yes"
                   Value="ApplicationFolderName"/>
  </Component>

When I build the installer this way, it actually creates a shortcut on Desktop. However, WiX seems to think that BSStrage is a file/application so it places a shortcut to an imaginary application called BSStrage in the location C:\ProgramData\MT. But double clicking on it dosen't help as there is no program that can be used to open it.

Obviously I'm doing it wrong here. Can someone please help me with this, so as how to overcome this problem. Note that I'm extremely new to Wix (it's been only two days) and has never worked with it before. Any code sample would be of great help.

© Stack Overflow or respective owner

Related posts about c#

Related posts about wix