This week's giveaway is in the Testing forum.
We're giving away four copies of TDD for a Shopping Website LiveProject and have Steven Solomon on-line!
See this thread for details.
Win a copy of TDD for a Shopping Website LiveProject this week in the Testing forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
  • Piet Souris
  • Himai Minh

System.getProperty("") and compatibility modes with new Windows OS's

Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
We have a java app that is installed on different Windows platforms, and we've been using System.getProperty("") for a long time to determine the OS the app is running under. We use this info to track how many installations we have under each Windows platform. Also, our app is packaged as an executable via InstallAnywhere.

With the newer versions of Windows (Vista, Windows 7, Windows Server 2008), we're usually getting the correct OS name back... so if it's installed under Windows 7 we're getting "Windows 7" back. However, under these new OSes, a user can set the "compatibility mode" to an older OS such as Windows XP. We're finding that the "" property is coming back as whatever OS is selected for this compatibility mode. For example, if the application is installed to Windows 7, but the executable's compatibility mode is set to Windows XP, then the call to System.getProperty("") is returning "Windows XP".

Does anyone know if there's a way to get the real OS? We're tossing around the idea of making an external system call or running another executable that writes the real OS name to a temporary file we can then read... but that's not foolproof either since someone can set the compatibility mode for that executable as well.
Java Cowboy
Posts: 16084
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to JavaRanch.

I don't think there is a pure-Java solution to this, since the problem is very Windows-specific. Creating a native executable that does Windows system calls and somehow finds out what the real operating system is sounds like something you could do. But you're really trying to work against the intention of Windows compatibility mode - the whole idea is ofcourse to make the app think that it works on an older Windows version.

Ultimately, the question is how well you trust your users. Do you really have users that deliberately want to trick you by making the software run in compatibility mode (what motives would they have to make you think they're running Windows XP?). Are there really that many users running your software in compatibility mode (what would be their reason to make it run in compatibility mode?) so that it seriously affects your statistics?
Are you here to take over the surface world? Because this tiny ad will stop you!
Free, earth friendly heat - from the CodeRanch trailboss
    Bookmark Topic Watch Topic
  • New Topic