...someplace, where there isn't any trouble? Do you suppose there is such a place, Toto?

Surprise, surprise! The windows installer lies!

Link: https://blogs.msdn.com/b/cjacks/archive/2009/05/06/why-custom-actions-get-a-windows-vista-version-lie-on-windows-7.aspx

Yesterday I lost sort of like two hours of work because of a behaviour of the Windows Installer that I haven't come across before. I was testing an installer of mine on Windows 7 and I was really surprised from the behaviour of a Custom Action (CA) in my installer. Inside the CA my code determined if it is running on Windows 7 or later and in that case, the CA was supposed to execute a certain piece of code. But that code never seemed to execute at all. I inspected the code, but there was no apparent bug in it. I wrote a small executable that did the same thing but that binary worked as expected. I added log messages to the code, but those log messages never appeared in the log file. Finally I attached the debugger and was baffled when I stepped over the code that executes the GetVersionEx API, our beloved old friend from kernel32. It returned major version 6 and minor version 0, which is the version number tuple for Windows Vista, not Windows 7. "Oh, stupid", I thought, "you thought you were testing on Windows 7, but it was actually a Window Vista VM". I fired up winver, but it showed that this was clearly Windows 7. So I started scratching my head and googling. Here is, where I found an answer. It turns out that this is on purpose. Beginning with Windows 7, the GetVersionEx API is shimmed with a VersionLie shim in msiexec.exe. Purportedly this is, because so many developers were not competent enough to properly determine the operating system version inside their CAs, so the Windows Installer Team (or the app compat team) decided to always lie to CAs from Windows 7 onwards. CAs will always think they are running on Windows Vista, no matter what the real operating system version is. This is quite unusual because up to now I was under the impression that VersionLies are only applied to third party processes, not MS's own programs, such as msiexec.exe.

The moral of the story is: Never call GetVersionEx from a CA. Do any conditioning by conditioning (yeah, I like to verb words!) your CA itself with the VersionNT property, not by conditioning inside your CA, even if you then end up with twice the number of CAs. I wonder if the fine folks from the WINE project got that right...

Trackback address for this post

This is a captcha-picture. It is used to prevent mass-access by robots.
Please enter the characters from the image above. (case insensitive)

Feedback awaiting moderation

This post has 192 feedbacks awaiting moderation...

Leave a comment


Your email address will not be revealed on this site.
(Line breaks become <br />)
(For my next comment on this site)
(Allow users to contact me through a message form -- Your email will not be revealed!)
This is a captcha-picture. It is used to prevent mass-access by robots.
Please enter the characters from the image above. (case insensitive)