0
votes

I'm working on a C# application. I've an installer Wix and I want to create shortcuts for my application. After some researches I found a the code to create shortcuts for desktop and start menu.

There is my code :

<Directory Id="TARGETDIR" Name="SourceDir">
  <Directory Id="ProgramMenuFolder">
    <Directory Id="ApplicationProgramsFolder" Name="$(var.compagny)"/>
  </Directory>
  <Directory Id="DesktopFolder" SourceName="Desktop"/>
</Directory>

<!-- Shortcuts -->
<DirectoryRef Id="ApplicationProgramsFolder">
  <Component Id="ApplicationShortcut" Guid="*">
    <Shortcut Id="ApplicationStartMenuShortcut"
              Name="$(var.product)"
              Description="$(var.product) application"
              Target="MyApplication.exe"
              WorkingDirectory="INSTALLFOLDER"/>
    <RemoveFolder Id="ApplicationProgramsFolder" On="uninstall"/>
    <RegistryKey Root="HKCU" Key="SOFTWARE\$(var.compagny)\$(var.product)">
      <RegistryValue  Name="installed" Type="integer" Value="1" KeyPath="yes" />
    </RegistryKey>
  </Component>
</DirectoryRef>
<DirectoryRef Id="DesktopFolder">
  <Component Id="ApplicationShortcutDesk" Guid="*">
    <Shortcut Id="ApplicationStartDeskShortcut"
              Name="$(var.product)"
              Description="$(var.product) application"
              Target="MyApplication.exe"
              WorkingDirectory="INSTALLFOLDER"/>
    <RemoveFolder Id="DesktopFolder" On="uninstall"/>
    <RegistryKey Root="HKCU" Key="SOFTWARE\$(var.compagny)\$(var.product)">
      <RegistryValue Name="installed" Type="integer" Value="1" KeyPath="yes"/>
    </RegistryKey>
  </Component>
</DirectoryRef>

<Feature Id="ProductFeature" Title="$(var.product)" Level="1">
  <ComponentRef Id="ApplicationShortcut"/>
  <ComponentRef Id="ApplicationShortcutDesk"/>
</Feature>

After that a register is created in HKCU\SOFTWARE\MyCompagny\Product with key installed. But there is no shortcut.

What did I miss ?

Edit:

There are the log :

MSI (s) (5C:B8) [14:51:31:801]: Executing op: ActionStart(Name=CreateShortcuts,Description=Creating shortcuts,Template=Shortcut: [1])

Action 14:51:31: CreateShortcuts. Creating shortcuts

MSI (s) (5C:B8) [14:51:31:802]: Executing op: IconCreate(Icon=icone.ico,Data=BinaryData)

CreateShortcuts: Shortcut: icone.ico

MSI (s) (5C:B8) [14:51:31:808]: Executing op: SetTargetFolder(Folder=23\MyCompagny)

MSI (s) (5C:B8) [14:51:31:810]: SHELL32::SHGetFolderPath returned: C:\ProgramData\Microsoft\Windows\Start Menu\Programs

MSI (s) (5C:B8) [14:51:31:810]: Executing op: SetTargetFolder(Folder=25)

MSI (s) (5C:B8) [14:51:31:812]: SHELL32::SHGetFolderPath returned: C:\Users\Public\Desktop

MSI (s) (5C:B8) [14:51:31:812]: Executing op: ActionStart(Name=WriteRegistryValues,Description=Writing system registry values,Template=Key: [1], Name: [2], Value: [3])

Action 14:51:31: WriteRegistryValues. Writing system registry values

MSI (s) (5C:B8) [14:51:31:812]: Executing op: ProgressTotal(Total=2,Type=1,ByteEquivalent=13200)

MSI (s) (5C:B8) [14:51:31:813]: Executing op: RegOpenKey(Root=-2147483647,Key=SOFTWARE\MyCompagny\MyApplication,,BinaryType=0,,)

MSI (s) (5C:B8) [14:51:31:813]: Executing op: RegAddValue(Name=installed,Value=#1,)

WriteRegistryValues: Key: \SOFTWARE\MyCompagny\MyApplication, Name: installed, Value: #1

MSI (s) (5C:B8) [14:51:31:813]: Executing op: RegAddValue(Name=installed,Value=#1,)

WriteRegistryValues: Key: \SOFTWARE\MyCompagny\MyApplication, Name: installed, Value: #1

2
Can it be a problem with the Guid ? (I don't know how it works) - A.Pissicat

2 Answers

1
votes

You've used the DesktopFolder property improperly.

Your shortcut I think is going into C:\Desktop\

This is because you renamed the Well defined property "DesktopFolder" to reference "Desktop" so now you are putting a shortcut at [TARGETDIR]\[DesktopFolder] which as mentioned above will usually be C:\Desktop\

You want to use

<Directory Id="TARGETDIR" Name="SourceDir">
  <Directory Id="ProgramMenuFolder">
    <Directory Id="ApplicationProgramsFolder" Name="$(var.compagny)"/>
  </Directory>
  <Directory Id="DesktopFolder"/>
</Directory>

notice no Name="" on the DesktopFolder.

Also you should definitely remove

<RemoveFolder Id="DesktopFolder" On="uninstall"/>

from the ApplicationShortcutDesk component, I would say only ever use RemoveFolder on folders you know you own and have created with the install.

0
votes

You need to make sure that your Shortcut Component is referenced in your Feature list. Here's an example:

<Feature Id="ProductFeature" Title="ProductTitle" Level="1">
    <ComponentRef Id='ApplicationShortcutDesk' />
</Feature>

Hope that helps!