views:

330

answers:

2

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.

A: 

The slashes in your Shortcut/@Target should be backslashes. Explorer is probably interpreting your shortcut as "Launch CommonAppDataFolder with switches /MTK and /BSStrage". At least, that's my first guess.

Rob Mensching
A: 

I changed my requirements a bit and got the code to work as follows. Change being now I create a shortcut to the ProgramData folder.

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

It works fine and creates the shortcut fine. However there is one problem since it creates the shortcut on AllUsers Desktop while I want it to be created on the Current User's desktop. What change should I do?

Also note that my installer performs a all-user install, and I'm not at liberty to change that. I merely needs a way to create this shortcut on Current User's desktop while the installer can still do a all-user install.

Sach