Batch to detect if system is a 32-bit or 64-bit

后端 未结 9 1411
心在旅途
心在旅途 2021-02-12 22:45

Does anybody know how to create a batch file that can shell one program if its a 64-bit system or shell another if its a 32-bit system?

9条回答
  •  感动是毒
    2021-02-12 23:00

    Check for %PROCESSOR_ARCHITECTURE% being x86:

    if %PROCESSOR_ARCHITECTURE%==x86 (
      rem 32 bit
    ) else (
      rem 64 bit
    )
    

    At least for the time being. On a server I have access to it's AMD64 but no clue how Itanium looks like, for example. But 32-bit versions always report x86.

    Another option, that also works on WoW64:

    for /f "skip=1 delims=" %%x in ('wmic cpu get addresswidth') do if not defined AddressWidth set AddressWidth=%%x
    
    if %AddressWidth%==64 (
      rem 64 bit
    ) else (
      rem 32 bit
    )
    

提交回复
热议问题