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

后端 未结 9 1414
心在旅途
心在旅途 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:05

    On Linux, you can simply use "arch" at the command line.

    ubuntu# arch
    x86_64
    

    On OSX (Snow Leopard), it returns "i386", even if you're on 64-bit hardware.

    0 讨论(0)
  • 2021-02-12 23:10

    read this.

    http://blogs.msdn.com/b/david.wang/archive/2006/03/26/howto-detect-process-bitness.aspx

    0 讨论(0)
  • 2021-02-12 23:14

    It works without WMI too! I suggest:

     @echo off
     if /i "%processor_architecture%"=="AMD64" GOTO AMD64
     if /i "%PROCESSOR_ARCHITEW6432%"=="AMD64" GOTO AMD64
     if /i "%processor_architecture%"=="x86" GOTO x86
     GOTO ERR
     :AMD64
        rem do amd64 stuff
     GOTO EXEC
     :x86
        rem do x86 stuff
     GOTO EXEC
     :EXEC
        rem do arch independent stuff
     GOTO END
     :ERR
     @echo Unsupported architecture "%processor_architecture%"!
     pause
     :END
    
    0 讨论(0)
提交回复
热议问题