tags:

views:

34

answers:

2

I'm having trouble setting the working directory of a shortcut created as part of a WiX script. Here are the basics:

<!-- create a start menu shortcut. -->
<Directory Id="ProgramMenuFolder">
  <Directory Id="ApplicationProgramsFolder" Name="My Name">
    <Component Id="ApplicationShortcut" Guid="822A26AF-5231-4EDA-A18D-5DF15020BD94">
      <Shortcut Id="ApplicationStartMenuShortcut"
                Name="My Name"
                Description="My Description"
                Target="[INSTALLLOCATION]My.exe"
                WorkingDirectory="INSTALLLOCATION" />
      <RemoveFolder Id="ApplicationProgramsFolder" On="uninstall"/>
    </Component>
  </Directory>
</Directory>

<!-- Install the app. -->
<Directory Id="ProgramFilesFolder">
  <Directory Id="INSTALLLOCATION" Name="My Name">
    <Component Id="ProductComponent" Guid="4740357A-69D3-4626-A0F7-D0667C93A2CE">
      <File Id="My.exe" Name="My.exe" Source="My.exe" />
    </Component>
  </Directory>
</Directory>

This jives with examples I've seen, and the shortcut gets created, and it points to the right exe, but the shortcut has no working directory specified, and so the app doesn't find its local resources.

A: 

I think you need square brackets around your INSTALLLOCATION in the working directory attribute.

JoelHess
Tried that already, it didn't make any difference.
Josh Santangelo
A: 

You don't need to say [INSTALLLOCATION] because the ShortCut table defines the WkDir column describes "The name of the property that has the path of the working directory for the shortcut."

I would reccomend trying this:

<Directory Id="ProgramMenuFolder"> 
  <Directory Id="ApplicationProgramsFolder" Name="My Name"> 
  </Directory> 
</Directory> 

<!-- Install the app. --> 
<Directory Id="ProgramFilesFolder"> 
  <Directory Id="INSTALLLOCATION" Name="My Name"> 
    <Component Id="ProductComponent" Guid="4740357A-69D3-4626-A0F7-D0667C93A2CE"> 
      <File Id="My.exe" Name="My.exe" Source="My.exe" />
        <Shortcut Id="ApplicationStartMenuShortcut" 
                  Advertise="yes"
                  Name="My Name" 
                  Description="My Description" 
                  Directory="ApplicationProgramsFolder"
                  WorkingDirectory="INSTALLLOCATION">
          <Icon Id="My.exe" SourceFile="My.exe" />
        <Shortcut>
    </Component> 
  </Directory> 
</Directory> 
Christopher Painter
That creates the shortcut within the program files directory, rather than in the start menu -- but the shortcut does have the right working directory set, at least.
Josh Santangelo
Actually this pretty much worked -- I think you intended to have the shortcut element nested within the file element. Thanks!
Josh Santangelo
Actually I tabbed it wrong. It's correct to not be a child of File because as an advertised shortcut it points to the keyfile of the component. See this example: http://iswix.codeplex.com/SourceControl/changeset/view/53668#841603
Christopher Painter