Win a copy of Terraform in Action this week in the Cloud 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 ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

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

 
Greenhorn
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("os.name") 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 "os.name" 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("os.name") 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
88
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?
 
reply
    Bookmark Topic Watch Topic
  • New Topic