I have a shortcut definition like this:
<Component Id="PowershellShortcut" Guid="{12345678-1234-1234-1234-1234567890AB}">
<Condition>POWERSHELL_INSTALL_LOCATION</Condition>
<Shortcut Id="PowershellStartMenuShortcut"
Name="Powershell Environment"
Description="Powershell Environment"
Target="[POWERSHELL_INSTALL_LOCATION]"
Arguments="-PSConsoleFile "[#Powershell.Environment]"" />
</Component>
I want to pass the path to the resultant .lnk
file into a CustomAction. I've tried various things, e.g.:
<CustomAction Id="SetCustomActionData_ElevatePowershellShortcut" Return="check"
Property="ElevatePowershellShortcut"
Value="<WHAT-GOES-HERE?>" />
Where I've tried the following in place of <WHAT-GOES-HERE?>
:
.lnk
file is in, but not the file itself<File>
elements...An alternative would be to keep using the [$PowershellShortcut]
value and also pass in the name of the .lnk
file. Which would be the <Shortcut>
's Name
attribute. I'm not sure how to get at it, either...
The reason I want to do this is that we've already had a case where the Name
of the shortcut was changed, and everything stopped working, so we don't want to have to update the name/path of the shortcut in more than one place.
Just after I wrote this question, I came up with a solution. It's not quite what I asked for, but it solved my problem, so I'm posting it. If somebody can figure out how to do what I actually asked for, I will mark their answer as the correct one, although my solution is fairly clean and straight forward.
I ended up defining the following variable in my WiX define file:
<?define PowershellShortcutName="Powershell Environment" ?>
and then I set the <Shortcut Name="$(var.PowershellShortcutName)">
and the CustomAction
to:
<CustomAction Id="SetCustomActionData_ElevatePowershellShortcut" Return="check"
Property="ElevatePowershellShortcut"
Value="[$PowershellShortcut]$(var.PowershellShortcutName).lnk" />
Everything works like it should now.