WiX: Prevent 32-bit installer from running on 64-bit Windows
Asked Answered
F

4

19

Due to user confusion, our app requires separate installers for 32-bit and 64-bit versions of Windows. While the 32-bit installer runs fine on win64, it has the potential to create support headaches and we would like to prevent this from happening.

I want to prevent the 32-bit MSI installer from running on 64-bit Windows machines. To that end I have the following condition:

<Condition Message="You are attempting to run the 32-bit installer on a 64-bit version of Windows.">
  <![CDATA[Msix64 AND (NOT Win64)]]>
</Condition>

With the Win64 defined like this:

<?if $(var.Platform) = "x64"?>
<?define PlatformString = "64-bit"?>
<?define Win64 ?>
<?else?>
<?define PlatformString = "32-bit"?>
<?endif?>

Thing is, I can't get this check to work right. Either it fires all the time, or none of the time. The goal is to check presence of the run-time msix64 variable against the compile-time Win64 variable and throw an error if these don't line up, but the logic is not working how I intend it to. Has anyone come up with a better solution?

Fayina answered 16/3, 2010 at 22:14 Comment(0)
L
16

Include the Condition element only in your 32-bit package (i.e., using ?if? preprocessor statement). The Condition would be "NOT Msix64": Launch conditions are things that must be true, so if Msix64 is set, the launch condition would fail and that means it's an x64 OS and a 32-bit package and the correct thing to do is to block.

Lepper answered 17/3, 2010 at 17:19 Comment(2)
This ended up doing the trick. My mistake was getting the logic backwards for Condition.Fayina
Msix64 requires Windows Installer 3.1 which is not present on XP by default (see msdn.microsoft.com/en-us/library/aa370522(v=VS.85).aspx)Stereotropism
E
7

We use the following...

<?if $(var.ProcessorArchitecture)=x86 ?>
<Condition Message="!(loc.LaunchCondition_Error64)">
    <![CDATA[Installed OR Not VersionNT64]]>
</Condition>
<?endif?>
Exsect answered 18/3, 2010 at 1:10 Comment(1)
VersionNT64 requires Windows Installer 4.0 (see msdn.microsoft.com/en-us/library/windows/desktop/aa372497.aspx)Mei
S
3

The condition element works with windows installer properties, which exist during an installation.

However, you are defining a Win64 as a wix variable, not a windows installer property. Wix variables only exist while the setup is created. You have to reference them as $(var.MyWixVariable) where you use them, and the wix preprocessor will then replace them with their defined value.

I would try this instead:

<?if $(var.Platform) = "x64"?>
<?define PlatformString = "64-bit"?>
<Property Id="Win64" Value="1" />
<?else?>
<?define PlatformString = "32-bit"?>
<?endif?>

If $(var.Platform) has the right value when the setup is created, then this will cause a "Win64" property to be recorded in the windows installer database (i.e. the MSI file) and the property will be available during installation for use in a condition element.

Strangles answered 17/3, 2010 at 0:29 Comment(2)
This throws an error when run through light on Wix 3.6 indicating that the nested Property element cannot be placed with the <?> syntax.Helsie
@JonSamwell: These processing instructions (<?...?>) are intended for the preprocessor in candle.exe. Light.exe should never see them if you are using wix correctly.Strangles
S
3

Add this condition

<Condition Message="This is designed for 32bit OS">%PROCESSOR_ARCHITECTURE ~= "x86" AND %PROCESSOR_ARCHITEW6432 &lt;&gt; "amd64"></Condition>

You could create one installer with a 32bit component and a 64bit component and put these two conditions in the respective components

<Component Id="bit32Component" Guid="..." Feature="ProductFeature">
    <Condition>%PROCESSOR_ARCHITECTURE~="x86" AND %PROCESSOR_ARCHITEW6432&lt;&gt;"amd64"></Condition>
</Component>
<Component Id="bit64Component" Guid="..." Feature="ProductFeature">
    <Condition>%PROCESSOR_ARCHITECTURE~="amd64" OR %PROCESSOR_ARCHITEW6432~="amd64"></Condition>
</Component>

here is a reference I used

http://blogs.msdn.com/david.wang/archive/2006/03/26/HOWTO-Detect-Process-Bitness.aspx

Schmit answered 17/3, 2010 at 11:45 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.