简体   繁体   English

WiX:防止32位安装程序在64位Windows上运行

[英]WiX: Prevent 32-bit installer from running on 64-bit Windows

Due to user confusion, our app requires separate installers for 32-bit and 64-bit versions of Windows. 由于用户混淆,我们的应用程序需要单独的安装程序,用于32位和64位版本的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. 虽然32位安装程序在win64上运行良好,但它有可能造成支持问题,我们希望防止这种情况发生。

I want to prevent the 32-bit MSI installer from running on 64-bit Windows machines. 我想阻止32位MSI安装程序在64位Windows机器上运行。 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: 使用Win64定义如下:

<?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. 目标是检查运行时msix64变量对编译时Win64变量的存在,并抛出错误,如果这些不排队,但逻辑不起作用我打算如何。 Has anyone come up with a better solution? 有没有人想出更好的解决方案?

Include the Condition element only in your 32-bit package (ie, using ?if? preprocessor statement). 仅在您的32位软件包中包含Condition元素(即,使用?if?预处理程序语句)。 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. 条件将是“NOT Msix64”:启动条件必须为true,因此如果设置了Msix64,则启动条件将失败,这意味着它是x64操作系统和32位软件包,正确的做法是块。

We use the following... 我们使用以下......

<?if $(var.ProcessorArchitecture)=x86 ?>
<Condition Message="!(loc.LaunchCondition_Error64)">
    <![CDATA[Installed OR Not VersionNT64]]>
</Condition>
<?endif?>

The condition element works with windows installer properties, which exist during an installation. condition元素适用于安装期间存在的Windows安装程序属性。

However, you are defining a Win64 as a wix variable, not a windows installer property. 但是,您将Win64定义为wix变量,而不是Windows安装程序属性。 Wix variables only exist while the setup is created. Wix变量仅在创建设置时存在。 You have to reference them as $(var.MyWixVariable) where you use them, and the wix preprocessor will then replace them with their defined value. 您必须将它们作为$(var.MyWixVariable)引用它们, $(var.MyWixVariable)预处理器将用它们定义的值替换它们。

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 (ie the MSI file) and the property will be available during installation for use in a condition element. 如果$(var.Platform)在创建安装程序时具有正确的值,那么这将导致“Win64”属性记录在Windows安装程序数据库(即MSI文件)中,并且该属性在安装期间可用以供使用在条件元素中。

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 您可以使用32位组件和64位组件创建一个安装程序,并将这两个条件放在相应的组件中

<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 http://blogs.msdn.com/david.wang/archive/2006/03/26/HOWTO-Detect-Process-Bitness.aspx

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM