WiX condition properties passed from command line don't work?
Asked Answered
B

3

4

I have a property for whether to install shortcuts that need to be passed via command line arguments. The conditions seem to work when I set the properties within the wxs file, but they seem to be ignored when setting them through the command line. From the log I see that they are being set:

MSI (s) (24:C8) [11:01:32:234]: PROPERTY CHANGE: Modifying INSTALLSTARTUPSHORTCUT property. Its current value is '0'. Its new value: '1'.
MSI (s) (24:C8) [11:01:32:234]: PROPERTY CHANGE: Modifying INSTALLSTARTMENUSHORTCUT property. Its current value is '0'. Its new value: '1'.
MSI (s) (24:C8) [11:01:32:234]: PROPERTY CHANGE: Modifying INSTALLDESKTOPSHORTCUT property. Its current value is '0'. Its new value: '1'.

However, they the shortcuts aren't being installed.

Also, it seems like since they need to be in their own component to be able to set conditions on them, they can no longer be advertised shortcuts. How would you get conditionally installed advertised shortcuts?

Current shortcut code:

<Property Id="INSTALLSTARTMENUSHORTCUT" Value="0"/>
...
<Component Id="StartMenuShortcut" Guid="MY-GUID">
  <Condition>INSTALLSTARTMENUSHORTCUT</Condition>
  <Shortcut Id="StartMenuServerShortcut"
    Directory="ProgramMenuDir"
    Name="Application Name" WorkingDirectory="INSTALLDIR" Advertise="no"
    Target="[!FileEXE]"
    Icon="Icon.ico" />
</Component>

And repeated for other shortcuts

Edit:

Trying what Sacha suggested and adding the following:

<Property Id="INSTALLSTARTUPSHORTCUT" Value="0" Secure="yes"/>
<Property Id="INSTALLDESKTOPSHORTCUT" Value="0" Secure="yes"/>
<Property Id="INSTALLSTARTMENUSHORTCUT" Value="0" Secure="yes"/>

Now it installs all the shortcuts even though they're set to 0 both in the xml and on the command line. The command line I'm passing is:

msiexec /i MySetup.msi INSTALLSTARTUPSHORTCUT=0 INSTALLDESKTOPSHORTCUT=0 INSTALLSTARTMENUSHORTCUT=0 /l*v inst.log /qb

tried putting the values in quotes and still no go. Not shown here, but I was successful in manipulating the ALLUSERS property to do per-user or per-machine registries by doing ALLUSERS="" or ALLUSERS="2" So passing in properties should be possible, but I'm not sure what I'm doing wrong.

Bionics answered 13/5, 2009 at 16:19 Comment(0)
R
10

Two things since there are two questions here:

  1. Advertised Shortcuts must be in the same Component that installs the File they point at. That is requried because the Windows Installer points an advertised Shorcut at the KeyPath of the Component. So, you can't use advertised Shorcuts if you want them to be optionally installed.

I have a blog post about how to create a shorcut and pass validation.

  1. The Properties you are using need to be marked secure to pass from the install UI process to the server-side. To do that just do

    <Property Id="INSTALLSTARTMENUSHORTCUT" Secure="yes"/>

Notice that I did not add a Value attribute. If you specify a Value, even if it is 0, then your INSTALLSTARTMENUSHORCUT will evaluate to TRUE. A blank/non-defined Property is FALSE, any other value is TRUE.

Redstone answered 20/5, 2009 at 18:44 Comment(3)
Thanks Rob. It seems inconsistent that if you put 0 in the condition property directly it evaluates to false, but in a property it evaluates to true.Bionics
I don't make the rules, I just live by them. <smile/>Redstone
And if you want to default to "yes" use conditions described here firegiant.com/wix/tutorial/com-expression-syntax-miscellanea/… instead of just evaluating whether a property is set at allJaneljanela
H
2

Have you tried marking the properties as secure?

<Property Id="INSTALLSTARTMENUSHORTCUT" Value="0" Secure="Yes" />

Looking at the documentation for the Shortcut Table I don't think you can get conditionally advertised shortcuts. We get around this by installing an Advertised start menu shortcut, and a regular desktop shortcut.

Hadlee answered 14/5, 2009 at 1:16 Comment(1)
Just tried and didn't seem to do it. Oddly though, when I added Secure="Yes" all the shortcuts installed even though they are set to Value="0" in the WiX fileBionics
D
0

If IIRC Advertise has to bet set at Yes

You have seen this example from MindCapers here, I had trouble with the Shorcuts until I created the registry entry.

Denison answered 13/5, 2009 at 19:21 Comment(1)
I can't set Advertised="yes" if it's not in the same component as the file it's linking to. And if it's in the same component I can't add a condition to only the shortcut and not the entire componentBionics

© 2022 - 2024 — McMap. All rights reserved.