Before starting to look at this, its important to be clear about what you mean by "64 bit".
You can have a 64 bit CPU, a 64 bit operating system and a 64 bit process running.
It is equally possible to have 64 bit CPU, a 32 bit operating system installed and a 16 bit process running.
The table below shows a few of the combinations you need to account for:
|CPU Hardware||Operating System||Process|
|Windows XP (16 bit compatibility)||32||32||16|
|Windows XP on new hardware||64||32||32|
|Windows 7+ on old hardware||32||32||32|
|Windows 7+ (32 bit compatibility)||64||64||32 (WOW)|
In Vista and greater, you can use wmic os get osarchitecture, or in WMI Win32_ComputerSystem/OSArchitecture sadly this is not supported in XP or 2003
There are a number of promising looking options in WMI and Systeminfo, but they all pertain to the OS not the CPU.
:: Installed OS
IF %PROCESSOR_ARCHITECTURE% == x86 (
IF NOT DEFINED PROCESSOR_ARCHITEW6432 Set _os_bitness=32
Echo Operating System is %_os_bitness% bit
Via David Wang’s blog post: Detect OS Bitness
On Windows 7, running C:\windows\SysWOW64\cmd.exe will launch a 32 bit instance of CMD.exe even if the OS is 64 bit. Applications that are compiled for a 32 bit processor will run in a similar way.
We can detect this by testing either the %ProgramFiles% or the %PROCESSOR_ARCHITECTURE% environment variables:
32bit CMD process:
C:\Windows\SysWOW64> set ProgramFiles
ProgramFiles=C:\Program Files (x86)
C:\Windows\SysWOW64> echo %PROCESSOR_ARCHITECTURE%
64 bit CMD process:
C:\Windows\System32> set ProgramFiles
C:\Windows\System32> echo %PROCESSOR_ARCHITECTURE%
Using this with a conditional IF to detect process bitness in a script:If %PROCESSOR_ARCHITECTURE% == x86 ( Set _ps_bitness=32 ) ELSE ( Set _ps_bitness=64) Echo Process is %_ps_bitness% Bit
64 bit versions of Windows have dynamic system folders C:\Windows\sys* to support both 64 and 32 bit programs.
PowerShell.exe, CMD.exe and many other programs are available as both 32 bit or 64 bit.
The dynamic sys folders will appear differently to a 32 bit session and a 64 bit session:
32 bit folder 64 bit folder 32 bit session C:\Windows\system32\ C:\Windows\sysNative\ 64 bit session C:\Windows\sysWOW64\ C:\Windows\system32\
By default a 32 bit session will launch 32bit executables from C:\Windows\System32\ but you can still choose to launch 64 bit executables by specifying SysNative
By default a 64 bit session will launch 64bit executables also from C:\Windows\System32\ but you can still choose to launch 32 bit executables by specifying sysWOW64.
The sysNative folder is not visible to 64 bit processes or programs and cannot been seen in Windows Explorer.
%ProgramFiles% = 32 bit programs on 32 bit systems "C:\Program Files" %ProgramFiles% = 64 bit programs on 64 bit systems "C:\Program Files" %ProgramFiles(x86)% = 32 bit programs on 64 bit systems "C:\Program Files (x86)"
To run a 32 bit program or utility on a 64 bit OS, the 32 bit executable file must be called from C:\Windows\SysWOW64\
if you run a 32 bit shell (such as C:\windows\syswow64\cmd.exe) and then try to launch a command, it will always look for a 32 bit version of the command, even if you explicitly use a full path to system32, the 32 bit shell will redirect to the 32 bit equivalent in syswow64 (if no 32 bit version of the command is found, then the new process will fail to launch.)
To run a 64 bit program from a 32 bit process use the virtual folder C:\Windows\sysnative
In many cases this is not needed as most utilities (e.g. ping.exe) have both a 32 bit and 64 bit version, however a few utilities (nbtstat, bcdedit) are only available as a 64-bit executable.
By default, running CMD from the start menu will launch a 64 bit process (C:\Windows\System32\cmd.exe)
“It's not so much that we're afraid of change or so in love with the old ways, but it's that place in between that we fear... it's like being between trapezes” ~ Marilyn Ferguson
Q556009 - How to check if a computer is running a 32 bit or 64 bit Operating System.