views:

2122

answers:

3

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).

+1  A: 

Not with 100% certainty as you say the browser could be a 32bit version while the OS a 64bit.

To detect the browser, please try the following code:

<script language=javascript>   
  <!--   
  document.write("CPU :"+window.navigator.cpuClass);   
  //-->   
</script>

CPU : ia64

For IE.

http://msdn.microsoft.com/en-us/library/ms531090%28VS.85%29.aspx

Commercial Product : https://www.cyscape.com/showbrow.aspx

Pino
This does not address original question. This produces "x86" on a 64 bit Windows 7 box using 32-bit IE. Question was asking to detect system bitness and os, not browser bitness.
Pete
+8  A: 

You can check the window.navigator.platform and the window.navigator.cpuClass.

I'm not sure your situation, but I would consider just doing what most other sites do and let the user choose which download they get. They could be downloading it for another machine, to put on a flash device, or just may simply want the 32-bit version to run on their 64-bit box. Whatever reason, I would rather have the choice.

RC
+3  A: 

The most reliable solution would be to create a 32bit loader application that detects the architecture and then downloads and installs the appropriate version of your application.

I've checked the other two answers from RC and Pino. They both do not work because of the same problem as you suggest - 32-bit IE on 64-bit Windows will wrongly identify the platform as 32-bit. As most people run 32-bit IE on 64-bit Windows (many plugins e.g. Flash are not available in 64-bit), there will be a lot of innacurate identifications

Lee

Lee Atkinson
Why mark this down and not give a reason?
Lee Atkinson
I'm guessing someone (not me) voted it down because it doesn't directly answer the question. However, it is an alternative way of accomplishing what I want to do.
user9876
Voted up, because of mention of 32bit browsers on 64-bit Windows...
Zach
32 bit IE includes the WOW64 token, so it would be easy to pick out.
George Edison