Dynamically assigning name to shortcut at run time

2020-07-25 02:53发布

I want to assign different names to a shortcut based on user input. Is this feasible using the WiX toolset? I have tried assigning value of property to Name attribute of Shortcut element but it does not work.

标签: wix wix3.7
3条回答
放我归山
2楼-- · 2020-07-25 03:07

I use this workaround:

<CustomAction Id="SetShortcutFolder" Return="check" Property="ProgramMenuDir" Value="[ProgramMenuFolder][PRODUCTNAME]"></CustomAction>

<!--Setting up the shortcuts for the product-->
    <Directory Id="ProgramMenuFolder" Name="Programs">
       <Directory Id="ProgramMenuDir" Name="TempName"/>
    </Directory>



<!--Set the install path to match the path of the product already installed-->
<Custom Action="SetInstallPath" Before="CostFinalize"/>

Hope this helps..:)

查看更多
叛逆
3楼-- · 2020-07-25 03:27

The Name column of the Shortcut Table isn't of type Formatted therefore it isn't possible to use [PROPERTY] to mutate it at runtime.

The only ways I know how to do it are:

  1. Skip the shortcut table and write a custom action to handle it yourself.
  2. Write a custom action to dynamically author the ShortCut table at runtime using SQL TEMPORARY syntax.
  3. There might be an extension out there that has implemented #2.
查看更多
Juvenile、少年°
4楼-- · 2020-07-25 03:32

If you are doing lots of translations and say lots of permutations, then this is a real drawback. Instead of using WIX (which is one of the most obfuscated API's I've ever used) you may prefer to simply write the shortcut using the Windows API.

查看更多
登录 后发表回答