Why %processor_architecture% always returns x86 in

2019-01-07 09:50发布

I am trying to retrieve the environment variable to detect whether the system is 32 or 64 bit. But on 64 bit server the environment variable %processor_architecture% is returning x86 instead of AMD64.

Does anyone has any clue about this?

9条回答
劳资没心,怎么记你
2楼-- · 2019-01-07 10:24

Are you actually running a 64-bit version of Windows? If you are running 32-bit Windows on a 64-bit-capable CPU, you will still get x86.

查看更多
在下西门庆
3楼-- · 2019-01-07 10:26

Apologize for the grave dig. However, the processor architecture environmental variable is accessible via powershell ...

$env:PROCESSOR_ARCHITECTURE
查看更多
Rolldiameter
4楼-- · 2019-01-07 10:28

I found on my Win7HB x64 system:

msgbox wscript.createobject("wscript.shell").environment("system").item("processor_architecture") ' always "AMD64"

msgbox wscript.createobject("wscript.shell").environment("process").item("processor_architecture") ' "AMD64" if launched via System32, "x86" if launched via SysWOW64
查看更多
祖国的老花朵
5楼-- · 2019-01-07 10:31

I think part of the reason it is like this way is that the x86-64 architecture has to allow 32-bit programs to treat it as identical (as far as possible) to a 32-bit environment and make sure that 32-bit programs do not think it is 64-bit only (like the Itanium architecture).

This however makes it very frustrating to people who need to access the differences between the x86-64 architecture vs 32 bit architecture on Windows.

查看更多
倾城 Initia
6楼-- · 2019-01-07 10:32

Assuming 64bit PC with 64bit Windows installation.

%processor_architecture% returns x86 only when getting the value in 32bit programs. In 64bit programs it returns correctly AMD64.

Example: execute echo %processor_architecture% from:

  • 32bit Total Commander
  • 64bit Explorer
查看更多
孤傲高冷的网名
7楼-- · 2019-01-07 10:35

AMD64 is a brand of CPU which is based on the x86 architecture. x86-64 more precisely, which is the 64-bit extension of x86.

This also relates to bobince's answer.

This Knowledge Base article shows you how to determine if your system is 32-bit or 64-bit

查看更多
登录 后发表回答