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

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

问题描述

我可以在批处理文件中查看当前机器运行的是 64 位 操作系统还是 32 位 操作系统?

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

找到 这个 在线,现在对我来说已经足够了:

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

推荐答案

这是按照 Microsoft 的知识库参考 ( http://support.microsoft.com/kb/556009 ),我已经重新编辑成一个一行代码.

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.

如下面的完整批处理文件所示,它设置的环境变量 OS 等于 32BIT64BIT,您可以根据需要使用.

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 "HKLMHardwareDescriptionSystemCentralProcessor" | 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天全站免登陆