批处理文件检查64位或32位操作系统 [英] batch file to check 64bit or 32bit OS

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

问题描述

我可以在批处理文件中检查当前计算机是否正在运行 64位操作系统或 32位 * 操作系统 *?

EDIT:



找到在线,现在:

解决方案

这是 正确 检查每个Microsoft的知识库引用( http://support.microsoft.com/kb/556009 )我有重新编辑为一行代码。



它不依赖于任何环境变量或文件夹名称,而是直接在注册表中检查。



如下面的完整批处理文件所示,它将环境变量 OS 设置为 32BIT 64BIT <

  @echo OFF 

reg查询HKLM \硬件\Description\System\CentralProcessor\0| find / ix86> NUL&&设置OS = 32BIT || set OS = 64BIT

如果%OS%== 32BIT echo这是一个32位操作系统
如果%OS%== 64BIT echo这是一个64位操作系统


Can I check to see if current machine is running 64bit OS or 32bit *OS* inside a batch file?

EDIT:

Found this online and it is good enough to me now:

解决方案

This is the correct way to perform the check as-per Microsoft's knowledgebase reference ( http://support.microsoft.com/kb/556009 ) that I have re-edited into just a single line of code.

It doesn't rely on any environment variables or folder names and instead checks directly in the registry.

As shown in a full batch file below it sets an environment variable OS equal to either 32BIT or 64BIT that you can use as desired.

@echo OFF

reg Query "HKLM\Hardware\Description\System\CentralProcessor\0" | find /i "x86" > NUL && set OS=32BIT || set OS=64BIT

if %OS%==32BIT echo This is a 32bit operating system
if %OS%==64BIT echo This is a 64bit operating system

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

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