批处理以检测系统是32位还是64位 [英] Batch to detect if system is a 32-bit or 64-bit

查看:143
本文介绍了批处理以检测系统是32位还是64位的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人知道如何创建一个批处理文件,该批处理文件可以在一个程序为64位系统的情况下对一个程序进行外壳程序,或者在其程序为32位系统的情况下对另一程序进行外壳程序化吗?

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?

推荐答案

检查%PROCESSOR_ARCHITECTURE% x86

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

在服务器上,我可以访问它的 AMD64 ,但是不知道例如Itanium的样子。但是32位版本始终报告 x86

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.

另一种方法也适用于WoW64:

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
)

这篇关于批处理以检测系统是32位还是64位的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆