Detect 64-bit or 32-bit Windows from User Agent or Javascript?

user9876 picture user9876 · Nov 16, 2009 · Viewed 66.2k times · Source

I want to offer the right version of a download. The versions I have are:

  • 32-bit Windows
  • 64-bit Windows
  • Linux

Detecting Linux using the User Agent field is easy; but is it possible to reliably figure out if Windows is 32-bit or 64-bit?

Users might be using weird browsers - IE and Firefox are common, and we probably have an Opera user somewhere; maybe a Chrome user too. I know that 64-bit Windows 7 ships with 32-bit and 64-bit versions of IE, and I'd like to send them both the 64-bit version of my download.

(Edited to add: I know that I should provide all the options, and I will. But people don't read the options. So I wanted to provide the right download by default, to improve usability. Of course, while this is helpful if I get it right, it's extremely unhelpful if I get it wrong. And from the answers so far, it doesn't look like there's a reliable way of doing this).

Answer

saschabeaumont picture saschabeaumont · Jul 29, 2011

Try this, looks for WOW64 (32-bit on 64-bit) or Win64 (native 64-bit) in the user-agent string.

    if (navigator.userAgent.indexOf("WOW64") != -1 || 
        navigator.userAgent.indexOf("Win64") != -1 ){
       alert("This is a 64 bit OS");
    } else {
       alert("Not a 64 bit OS");
    }