Search code examples
windowswixwindows-installerinstallshieldwix3.8

WIX Toolset - Custom Action command doesn't correctly detect Windows 10 version


I have an installer that deploys and runs a separate .exe file to deploy drivers to a system. Unfortunately, Microsoft seems to have dropped support for the VersionNT macro in Windows 10 and onward, so I implemented an approach suggested in another post: write a function to query kernel32.dll for its version number, and compare against a sentinel value (10.0.10240.16384).

Here's the catch: when I run this command directly from an Administrative Console, the command correctly detects the version of Windows I'm running.

Current Windows Version: 10.0.10240.16384 - Cutoff Version: 10.0.10240.16384

However, when the command is executed as a Custom Action from my WIX Toolset installer, it seems to think I'm using an older version of Windows. My best guess at this point is the installer or the Custom Action command running in some sort of automatic compatibility mode.

Current Windows Version: 6.2.10240.16384 - Cutoff Version: 10.0.10240.16384

How can I proceed? The VersionNT abandonment is frustrating as it is, with the new version API (ie: IsWindows10OrGreater()) only available on Win10 or later, so on older machines I have to dlopen/dlsym and test for failures. I don't know why it's so hard to create a simple int return_OS_Version(major, minor, release, revision,) function.


Solution

  • This is a bit of a hack (they do this, we do that...) but desperate times call for desperate measures....

    In all of the compatibility games MSFT is playing they only seem to be masking the Major and Minor but Build and revision. I've also worked out that on Win8 they mask it as 6.2 and on Win 10 they mask it as 6.3. So therefore I feel comfortable doing this:

    <Property Id="WIN10FOUND">
      <DirectorySearch Id="searchSystem" Path="[SystemFolder]" Depth="0">
        <FileSearch Id="searchFile" Name="advapi32.dll" MinVersion="6.3.10000.0"/>
      </DirectorySearch>
    </Property>