Setting working directory for a WiX shortcut

久未见 提交于 2019-12-07 15:58:53

问题


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.


回答1:


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> 



回答2:


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



来源:https://stackoverflow.com/questions/3876834/setting-working-directory-for-a-wix-shortcut

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!