2010-01-15 05:28:57 +0000 2010-01-15 05:28:57 +0000
26
26
Advertisement

如何通过命令行确定当前Windows的版本是32位还是64位?

Advertisement

用什么命令行来了解操作系统运行的是32位版本还是64位的Windows?

Advertisement
Advertisement

答案 (9)

34
34
34
2010-01-15 05:38:37 +0000

你可以通过WMI得到这个信息:

wmic OS get OSArchitecture

在我的系统中的例子。

C:\>wmic OS get OSArchitecture
OSArchitecture
32-bit
13
13
13
2011-10-20 15:43:09 +0000

我不能把答案附加到另一个帖子,所以这里。管道systeminfo的结果 - 需要相当多的时间,并写入控制台,所以不是命令文件的最佳解决方案(批处理脚本 - 无论如何,你喜欢叫他们B-) )。

即使是findstr - 在其他语言版本的windows上也找不到这个。在中欧语言的win7操作系统上,它也返回… “基于X86的”…的结果,但其他的东西,然后 “类型 "正在寻找。我不确定它是否会在其他语言的操作系统上有所不同。

可能 "wmic "方法是最可靠的–它直接询问操作系统。

其他可能的快速解决方法是检查一个变量(至少在我的win7上是这样的)。

echo %PROCESSOR_ARCHITECTURE%

好的–这是很长的记忆,但可能是set | findstr ARCH

当然 - 有些人可以修改系统变量,所以比wmic不可靠。但可以快速使用。

希望能帮到大家。

12
Advertisement
12
12
2012-06-24 15:23:24 +0000
Advertisement

在Windows下有许多方法可以检查处理器架构。

-微软还建议从注册表中读取硬件信息存储:

-你还可以检查x86版本的Program Files目录(或指向它的【环境变量】(http://en.wikipedia.org/wiki/Environment_variable#Default_Values_on_Microsoft_Windows))是否存在,因为它只会存在于64位系统上。与`PROCESSOR_ARCHITECTURE`变量不同的是,这并不依赖于命令提示符的运行方式,因为无论提示符如何打开,该目录都会存在(或不存在)。

这些方法可以结合在一个批处理文件中(例如cpuinfo.bat),并提供了一个很好的、快速的方法从标准的Windows NT命令提示符检查系统,而不需要运行其他程序或框架。

下面的批处理文件在32位和英特尔64位系统上进行了测试(请在AMD64上测试),在<1秒内给出了正确的结果:

@echo off

echo PROCESSOR_ARCHITECTURE var:
echo %PROCESSOR_ARCHITECTURE% | find /i "x86" > nul
if %errorlevel%==0 (
    echo 32-bit
) else (
    echo 64-bit
)
echo.

echo PROCESSOR_ARCHITECTURE reg:
reg query "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v PROCESSOR_ARCHITECTURE | find /i "x86" > nul
if %errorlevel%==0 (
    echo 32-bit
) else (
    echo 64-bit
)
echo.

echo CentralProcessor reg:
reg query "HKLM\Hardware\Description\System\CentralProcessor![Test results](https://i.stack.imgur.com/4mmyH.png)" | find /i "x86" > nul
if %errorlevel%==0 (
    echo 32-bit
) else (
    echo 64-bit
)
echo.

echo ProgramFiles(x86) var:
if not defined ProgramFiles(x86) (
    echo 32-bit
) else (
    echo 64-bit
)
echo.

echo ProgramFiles(x86) dir:
if not exist "%systemdrive%\Program Files (x86)" (
    echo 32-bit
) else (
    echo 64-bit
)
echo.

0x1&。

6
6
6
2012-06-24 14:16:19 +0000

我找不到OSArchitecture属性(根据hoebus的回答),所以我建议使用SystemType中的ComputerSystem属性代替。

在命令提示符下运行命令 wmic computersystem get systemtype,得到

C:\Windows\system32>wmic computersystem get systemtype  

SystemType x64-based PC
```。
4
Advertisement
4
4
2010-01-15 05:42:49 +0000
Advertisement

常规命令行:wmic OS get OSArchitecture (IIRC)

PowerShell:(gwmi win32_computersystem).SystemType

1
1
1
2010-01-15 06:35:11 +0000

你可以使用 “系统信息 ”

Start-> Run -> winmsd.exe

在 “系统摘要”/系统类型下,你可以找到操作系统版本

X64 -> 64 Bit X86 -> 32 Bit

JohnT在GUI中的答案;)

1
Advertisement
1
1
2010-01-15 05:38:45 +0000
Advertisement

如果你指的是windows操作系统,你可以使用vbscript的WMI

strComputer = "."    
Set objWMIService = GetObject("winmgmts{impersonationLevel=impersonate,authenticationLevel=Pkt}!\" & strComputer & "\root\cimv2")    
Set colSettings = objWMIService.ExecQuery("SELECT * FROM Win32_Processor")

For Each objProcessor In colSettings
Wscript.Echo "System Type: " & objProcessor.Architecture
Wscript.Echo "Processor: " & objProcessor.Description
Wscript.Echo "Address Width: "& objProcessor.AddressWidth
Next
```。
1
1
1
2012-03-28 07:21:13 +0000

进入 “开始” 运行,然后输入cmd。现在你将进入命令提示符。在那里你可以输入systeminfo,然后按回车键。这需要几秒钟的时间来获取所有的系统信息。你也可以找到处理器的数据。

Processor(s): 1 Processor(s) Installed.
                           [01]: x86 Family 15 Model 4 Stepping 10 GenuineIntel
  • x86 家庭意味着,你的处理器是 32 位的。 -x64 系列意味着你的处理器是 64 位的。

C:\Documents and Settings\mr85464>systeminfo

OS Name: Microsoft Windows XP Professional
OS Version: 5.1.2600 Service Pack 3 Build 2600
OS Manufacturer: Microsoft Corporation
OS Configuration: Member Workstation
OS Build Type: Multiprocessor Free
Product ID: 76487-640-3658033-23932
Original Install Date: 3/16/2012, 2:03:44 PM
System Up Time: 5 Days, 21 Hours, 35 Minutes, 51 Seconds
System Manufacturer: Dell Inc.
System Model: OptiPlex 210L
System type: X86-based PC
Processor(s): 1 Processor(s) Installed.
                           [01]: x86 Family 15 Model 4 Stepping 10 GenuineIntel
~2992 Mhz
``` - x86 家庭意味着你的处理器是 32 位的。
0
Advertisement
0
0
2013-06-25 16:19:58 +0000
Advertisement

我使用的简单代码。

:arch
set p | findstr /i AMD64 > nul
if not errorlevel 1 goto no64
goto eof
:no64
code to execute
:eof
Advertisement

相关问题

3
19
10
28
6
Advertisement