0

I received WiX code which used method from discussion VersionNT MSI property on Windows 10

My Product.wxs:

    <!-- begin hack - detect windows 10 -->
    <!-- Check if system is windows 10: https://stackoverflow.com/questions/31932646/versionnt-msi-property-on-windows-10 -->
    <Property Id="WIN10FOUND">
      <DirectorySearch Id="searchSystem" Path="[SystemFolder]" Depth="0">
        <FileSearch Id="searchFile" Name="advapi32.dll" MinVersion="6.3.10000.0"/>
      </DirectorySearch>
    </Property>

    <SetProperty Action="SetIsWindow10False"  Id="ISWIN10" After="FindRelatedProducts" Value="0"><![CDATA[WIN10FOUND = ""]]></SetProperty>
    <SetProperty Action="SetIsWindow10True"  Id="ISWIN10" After="FindRelatedProducts" Value="1"><![CDATA[WIN10FOUND <> ""]]></SetProperty>
    <!-- end hack - detect windows 10 -->

    <SetProperty Action="SetMyDriverPathToInstallDir"  Id="MYDRRVPATH" After="FindRelatedProducts" Value=""><![CDATA[ISWIN10 <> 1]]></SetProperty>
    <SetProperty Action="SetMyDriverPathToInstallDir_Win10"  Id="MYDRVPATH" After="FindRelatedProducts" Value="MyDrvDriverWin10\"><![CDATA[ISWIN10 = 1]]></SetProperty>

...

    <InstallExecuteSequence>
...
      <Custom Action="InstallMyDriverDriver" Before="InstallFinalize"><![CDATA[(NOT Installed AND NOT REMOVE) AND VDIENV <>"1" AND NOQOS <> "1" AND ISWIN10 = 0]]></Custom>
      <Custom Action="InstallMyDriverDriver10" Before="InstallFinalize"><![CDATA[(NOT Installed AND NOT REMOVE) AND VDIENV <>"1" AND NOQOS <> "1" AND ISWIN10 = 1]]></Custom>
...
    </InstallExecuteSequence>

But from installer logs I see that order of these properties is inverted

MSI (s) (FC:A4) [16:19:02:683]: Doing action: SetMyDriverPathToInstallDir
MSI (s) (FC:A4) [16:19:02:683]: Note: 1: 2205 2:  3: ActionText 
Action ended 16:19:02: SetCredentialFilter. Return value 1.
Action start 16:19:02: SetMyDriverPathToInstallDir.
MSI (s) (FC:A4) [16:19:02:684]: Skipping action: SetMyDriverPathToInstallDir_Win10 (condition is false)
MSI (s) (FC:A4) [16:19:02:684]: Doing action: SetIsWindow10False
MSI (s) (FC:A4) [16:19:02:684]: Note: 1: 2205 2:  3: ActionText 
Action ended 16:19:02: SetMyDriverPathToInstallDir. Return value 1.
MSI (s) (FC:A4) [16:19:02:685]: PROPERTY CHANGE: Adding ISWIN10 property. Its value is '0'.
Action start 16:19:02: SetIsWindow10False.
MSI (s) (FC:A4) [16:19:02:685]: Skipping action: SetIsWindow10True (condition is false)
MSI (s) (FC:A4) [16:19:02:685]: Skipping action: SetUpgrading (condition is false)
MSI (s) (FC:A4) [16:19:02:685]: Doing action: SetVersion
MSI (s) (FC:A4) [16:19:02:685]: Note: 1: 2205 2:  3: ActionText 
Action ended 16:19:02: SetIsWindow10False. Return value 1.
...
MSI (s) (FC:A4) [16:19:02:695]: PROPERTY CHANGE: Adding WIN10FOUND property. Its value is 'C:\Windows\SysWOW64\advapi32.dll'.

i.e. WIN10FOUND is defined first but called last path for draiver is defined last but called first

So, install path for driver is not corrected for Win10 and there are some problem.

Could someone help me to understand the reason which installer sets properties in incorrect order?

Eugene
  • 3
  • 1

2 Answers2

2

I guess your problem is caused because you are using this to set all your properties.

After="FindRelatedProducts"

Assume this is your initial execute sequence:

.
.
FindRelatedProducts

Then you say:

<SetProperty Action="SetIsWindow10False"  Id="ISWIN10" After="FindRelatedProducts" Value="0"><![CDATA[WIN10FOUND = ""]]></SetProperty>

You execute sequence will be like this:

.
.
FindRelatedProducts
SetIsWindow10False

Then you say:

<SetProperty Action="SetMyDriverPathToInstallDir_Win10"  Id="MYDRVPATH" After="FindRelatedProducts" Value="MyDrvDriverWin10\"><![CDATA[ISWIN10 = 1]]></SetProperty>

You execute sequence will be like this:

.
.
FindRelatedProducts
SetMyDriverPathToInstallDir_Win10
SetIsWindow10False

In the end your execute sequence will be like this:

.
.
FindRelatedProducts
SetMyDriverPathToInstallDir_Win10
SetMyDriverPathToInstallDir
SetIsWindow10True
SetIsWindow10False

If you need to have a specific sequence, then try something like this:

<SetProperty Action="SetIsWindow10False"  Id="ISWIN10" After="FindRelatedProducts" Value="0"><![CDATA[WIN10FOUND = ""]]></SetProperty>
<SetProperty Action="SetIsWindow10True"  Id="ISWIN10" After="SetIsWindow10False" Value="1"><![CDATA[WIN10FOUND <> ""]]></SetProperty>
<!-- end hack - detect windows 10 -->

<SetProperty Action="SetMyDriverPathToInstallDir"  Id="MYDRRVPATH" After="SetIsWindow10True" Value=""><![CDATA[ISWIN10 <> 1]]></SetProperty>
<SetProperty Action="SetMyDriverPathToInstallDir_Win10"  Id="MYDRVPATH" After="SetMyDriverPathToInstallDir" Value="MyDrvDriverWin10\"><![CDATA[ISWIN10 = 1]]></SetProperty>

This will result in something like this:

.
.
FindRelatedProducts
SetIsWindow10False
SetIsWindow10True
SetMyDriverPathToInstallDir
SetMyDriverPathToInstallDir_Win10

To check how the sequence will be executed, you can open your installer using Orca, this is the best tool the review the internals of an installer.

Rolo
  • 3,208
  • 1
  • 24
  • 25
  • I forgot to mention that you are setting two different properties "MYDRRVPATH" and "MYDRVPATH". I guess they should be the same. – Rolo Apr 03 '18 at 13:26
  • Thanks, it partially helped me: order all properties except WIN10FOUND was correct. But WIN10FOUND was defined after all other properties, so a value of ISWIN10 was incorrect. I tried to define WIN10FOUND by SetProperty and defined it first, but result was unchanged - version of advapi32.dll was checked last – Eugene Apr 04 '18 at 11:25
  • Well, the idea is the same, you need to make sure your SetProperty actions are happening after the AppSearch Action, if that is not the case, you'll need to move all your SetProperty Actions later in the execution sequence. If you followed my recommendation in the answer, you just need to change the first SetProperty Action, all others will be scheduled after that one. You could try replacing 'After="FindRelatedProducts"' with something like 'Before="InstallInitialize"' – Rolo Apr 04 '18 at 12:57
  • Thanks I resolved the issue. Yes, I changed 'After="FindRelatedProducts" to 'After="AppSearch" I installed Orca and saw that WIN10FOUND is defined in AppSearch – Eugene Apr 04 '18 at 13:27
  • Great! If you think this answer can help others, you can mark it as the correct answer. – Rolo Apr 04 '18 at 14:28
1

I wrote this answer a couple of weeks ago on this issue: Windows 10 not detecting on installshield. I suppose the WindowsBuild property described in this linked answer is one way to (currently) determine if you are on Windows 10 or not. The other options listed might also work - I just haven't tested them much. I am not sure exactly what your needs are.

As stated elsewhere you are not supposed to check for OS version anymore, but rather check for the OS feature you need (which could have been disabled by administrators). Another instance proving that in theory there should be no difference between theory and practice, but in practice there is.

I will check in with others on how to properly check these Windows 10 features. I am outdated.

Stein Åsmul
  • 39,960
  • 25
  • 91
  • 164
  • I tried to use VersionNT and WindowsBuild properties, but I received similar results for Win8.1 and Win10 VersionNT = 603 WindowsBuild = 9600 – Eugene Apr 04 '18 at 11:20
  • @Eugene - are you sure about that WindowsBuilld value? Just want to verify because [**according to this**](https://msdn.microsoft.com/en-us/library/windows/desktop/aa370556(v=vs.85).aspx) the **WindowsBuild** value should not be `9600` on `Windows 8` at least. Perhaps `Windows 8.1` sets `9600`? That OS version is missing from the linked documentation. – Stein Åsmul Apr 04 '18 at 13:34
  • 1) I checked it by SetProperty: <![CDATA[WindowsBuild > 9200]]> and looked value in log file. Last correct value was 9600 for both : Win8 and Win10(32 and 64). My Win8 was "Windows 8.1 Enterprize" – Eugene Apr 05 '18 at 06:53