How to detect if Windows is running 32 or 64 bit from a command script

From Yggenyk
Jump to navigation Jump to search


This is the simple and safe way to detect if Windows is running 64 bit (x64) or 32 bit (x86).

@if /I "%PROCESSOR_ARCHITECTURE%" == "AMD64" (
   echo We are running I a 64-bit process on a 64-bit OS
) else if /I "%PROCESSOR_ARCHITECTURE%" == "X86" (
   @if /I "%PROCESSOR_ARCHITEW6432%" == "AMD64" (
      echo We are running in a 32-bit process on a 64-bit OS (WOW64)
   ) else (
      echo We are running in a 32-bit process on a 32-bit OS
   )
)

This is documented in Microsoft's document:

WOW64 Implementation details - Environment Variables:


<google>ENGELSK</google>

id=siteTree