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.