Using %PROCESSOR_ARCHITECTURE% and %PROCESSOR_ARCHITEW6432%
Apparently, using %PROCESSOR_ARCHITECTURE%
is missleading. The variable reports the bitness of the process, not the bitness of the CPU.
%PROCESSOR_ARCHITEW6432%
can only be used for
WOW64.
[environment]::getEnvironmentVariable('PROCESSOR_ARCHITECTURE', 'machine')
for /f "tokens=3 usebackq" %a in (`reg query "HKLM\System\CurrentControlSet\Control\Session Manager\Environment" /v PROCESSOR_ARCHITECTURE`) do echo %a
Using %PROGRAMFILES(x86)%
Another approach seems to be to check if the environment variable %PROGRAMFILES(x86)%
(not the directory it points to) exists.
On 32-bit systems, the variable is not defined.
With wmic
With
wmic.exe
, the bitness (here refered to as
address with) can be determined like so
C:\> wmic cpu get addressWidth
Compare that with
C:\> wmic cpu get dataWidth
In an elevated command prompt, it can alternativelly be determined as follows
c:\> wmic os get osArchitecture