代码如下

@echo off

if "%PROCESSOR_ARCHITECTURE%" == "AMD64" (
   echo OS is 64bit
) ELSE IF "%PROCESSOR_ARCHITEW6432%" == "AMD64" (
   echo OS is 64bit
) ELSE (
   echo OS is 32bit
)

pause

 知识点:

The general idea is to check the following environment variables:

  • PROCESSOR_ARCHITECTURE – reports the native processor architecture EXCEPT for WOW64, where it reports x86.
  • PROCESSOR_ARCHITEW6432 – not used EXCEPT for WOW64, where it reports the original native processor architecture.
Environment Variable \ Program Bitness 32bit Native 64bit Native WOW64
PROCESSOR_ARCHITECTURE x86 AMD64 x86
PROCESSOR_ARCHITEW6432 undefined undefined AMD64

相关文章:

  • 2021-06-21
  • 2021-10-11
  • 2021-06-08
  • 2021-06-15
  • 2021-10-22
  • 2021-07-09
  • 2021-05-16
  • 2022-12-23
猜你喜欢
  • 2021-07-06
  • 2021-12-18
  • 2021-07-14
  • 2021-12-20
  • 2021-06-17
  • 2021-12-05
相关资源
相似解决方案