In this first part of the AppCompat Series, we will look at the significance of the OS version number change (6.1 in Windows 7) and how will this impact the existing applications. We will also look at the ways to mitigate them. The internal version number for Windows Vista is changed to 6.0 and 6.1 for Windows 7.  The GetVersion function will now return these version numbers to applications when queried { dwMajorVersion (6) and dwMinorVersion (0 or 1) }.
Any application that specifically checks for the OS version may get a higher version number which it may not be designed to handle. Setup packages may prevent themselves from installing and applications may prevent themselves from starting. Summing up, when a developer writes the code to check for the version numbers, there are some potentional issues with few of the applications.
  1. They only check the dwMajorVersion (These application will only install in Windows 2000,XP and Server 2003)
  2. They hardcoded the Version checks { if (majorVersion = 5 && minorVersion = 1) } (These application will only install in Windows XP)
  3. They implemented a wrong condition check { if (majorVersion > 5 && minorVersion > 1) }(Though the check condition loooks correct, this fails on Windows Vista)
The windows Team suggests the developers not to use the Version Numbers Checks in their applications !!
Mitigations
For new applications,
  1. Best Practice is to check for features instead of versions
  2. Look for OS versions greater than (>) compatible OS version
For existing applications,
Method 1: Compatiblity modes - Right click on the executable (StockViewer.exe in this example), goto the compatibilty tab. You will find all the previous operating systems. You can select the version in which it had worked/installed. Click on Apply and close the window.  Now you can invoke the executable.
comp_modes
Method 2: Applying Shims / Layers – If you are planning to deploy this fix to all the machines where this application needs to be installed. You can use this option. In this method, you can create a shim using Compatibilty Administrator and install this shim database file(sdb) file.
Compatibilty Administrator is a part of the Application Compatiblity Toolkit 5.5, which can be downloaded here
Step 1: Launch the Compatiblity Administrator, and create a new application fix
comadm
Step 2: Select the Compatiblity modes, Click next, and complete this dialog.
selectshim
On completing the dialog, you can see the shim which was just created.
shimsapplied
Step 3: Install the Shims which was just created.
installshim
Step 4: Now launch the application.
You can also deploy this sdb file to all the machines, where this application is to be installed.(you can either export these mitigations as an MSI, or run this in a command line using sdbinst.exe)
Both of these above methods add the Compatibility layers in the registry key – HKLM\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers\[app path]
PS: This OS fix is only an interim solution and cannot promise complete functionality. Getting back to the Vendor for the compatible version is always a better practice.


Version Check is a basic operation which every developer does while building applications. Wrong Conditions may cause Application Compatibility issues to both developers and users, when they look at migrating the existing applications to a newer OS. The Windows version is actually composed of a bunch of different fields, all packed into anOSVERSIONINFO structure.
The relevant parts of the OSVERSIONINFO are:
  • Major Version (dwMajorVersion)
  • Minor Version (dwMinorVersion)
  • Build # (dwBuildNumber)
List of Windows Client OS with their Version Numbers
Operating SystemVersion Number
Windows 1.01.04
Windows 2.02.11
Windows 3.03
Windows NT 3.13.10.528
Windows for Workgroups 3.113.11
Windows NT Workstation 3.53.5.807
Windows NT Workstation 3.513.51.1057
Windows 954.0.950
Windows NT Workstation 4.04.0.1381
Windows 984.1.1998
Windows 98 Second Edition4.1.2222
Windows Me4.90.3000
Windows 2000 Professional5.0.2195
Windows XP5.1.2600
Windows Vista6.0.6000
Windows 76.1.7600

Yochay Kiriaty says that “A lot can go wrong when version checking is misused. A user might experience a “silent fail” where the application simply fails to load and nothing happens. Or, a user might see a dialog box indicating something to the effect of “you must be running Microsoft Windows XP or later” when in fact, the computer is running Windows 7. Many other consequences to poor version checking can inconvenience users as well.”
Reference- Windows Team Blog