How can I determine if the current version of Windows is either 32-bit or 64-bit from the command line?

26

7

What's the command line to find out if the OS is running a 32-bit version or 64-bit of Windows?

Sreerag

Posted 2010-01-15T05:28:57.957

Reputation:

Question was closed 2013-12-01T05:14:31.963

@AlixAxel, well they said command-line, so presumably, if anything, Batch. – Synetech – 2012-06-24T15:27:44.163

In what language?! – Alix Axel – 2010-01-15T05:30:31.387

Answers

34

You can get this via WMI:

wmic OS get OSArchitecture

Example on my system:

C:\>wmic OS get OSArchitecture
OSArchitecture
32-bit

ZoogieZork

Posted 2010-01-15T05:28:57.957

Reputation: 466

XP?​​​​​​​​​​​​ – Synetech – 2012-06-24T14:22:27.563

I like this answer (gotta go learn me some WMI console :) ), but I gotta give it to "systeminfo" for keystrokes. ;) – Ƭᴇcʜιᴇ007 – 2010-01-15T05:45:15.470

19

Command line:

systeminfo | findstr /I type:

example output:

System type:               X86-based PC

X86 indicates a 32-bit system in this example.

(/I parameter indicates case-insensitive search)

Windows programmer

Posted 2010-01-15T05:28:57.957

Reputation:

be careful if your OS language is german(or maybe any other than englisch)! I have to change to systeminfo | findstr /I typ: as the whole entry is Systemtyp: x64-based PC – CeOnSql – 2016-03-31T14:14:57.150

systeminfo | findstr /C:"System Type" also retrieves the same information, but I guess longer text so less preferred. – Abhijeet – 2017-01-05T10:08:47.777

2But is "X86-based PC" the same as OSArchitecture 32-bit? You can run 32-bit Win XP on an x64 processor. – Michael Caron – 2012-03-27T15:52:38.553

I gave you a point for keystrokes, and then you made it longer. hehe :) – Ƭᴇcʜιᴇ007 – 2010-01-15T06:10:56.963

It's not my answer :P – John T – 2010-01-15T06:19:20.957

13

I can not attach answer to another post so here. Piping the result of systeminfo - is taking a quite good amount in time and writes to the console so is not the best solution for command files (batch scripts - anyhow You like to call them B-) ).

Even with the findstr - it does not find this on other language version of windows. On a central european language win7 os it also returns ..."X86-based"... on the result but something other on then the "type" were looking for. I am not sure that it can vary on other language variants of the os.

Probably the "wmic" method is the most reliable - it asks the os directly.

Other possible quick solution can be to examine a variable (at least working on win7 at me).

echo %PROCESSOR_ARCHITECTURE%

Ok - it is quite long to remember but possible a set | findstr ARCH can be remembered.

Sure - some can modify a system variable so not that reliable than wmic. But can be used quickly.

I hope I could help someone out.

RudyD

Posted 2010-01-15T05:28:57.957

Reputation: 141

I wasn't sure the echo command would work on my XP box because I've never seen this environment variable before (perhaps because I've never looked for it), but it does. +1 for a simple solution. – music2myear – 2011-10-20T15:58:20.767

12

There are numerous ways to check the processor architecture under Windows:

  • The fastest, easiest, and most compatible way to check the processor architecture in at least Windows 2000 and up is to examine the PROCESSOR_ARCHITECTURE environment variable:

    echo %PROCESSOR_ARCHITECTURE%

  • However, this can give different results, depending on the way in which the command-prompt is opened. To avoid getting “unexpected results” due to WoW64, you can read it directly from the registry (Microsoft made no less than two typos in the key):

    reg query "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v PROCESSOR_ARCHITECTURE

  • Microsoft also suggests reading the hardware information store from the registry:

    reg query "HKLM\Hardware\Description\System\CentralProcessor\0" /v Identifier

  • You can also check for the existence of the x86 version of the Program Files directory (or the environment variable that points to it) since it would only exist on a 64-bit system. Unlike the PROCESSOR_ARCHITECTURE variable, this is not dependant on the way that the command prompt is run since the directory exists (or not) regardless of how the prompt is opened:

    • ::via env-var
      if not defined ProgramFiles(x86) echo 32-bit

    • ::via file-system
      if not exist "%systemdrive%\Program Files (x86)" echo 32-bit

These methods can be combined in a single batch-file (e.g., cpuinfo.bat) and provides a nice, lightning fast way to check the system from a standard Windows NT command-prompt without needing to resort to running other programs or frameworks.

The batch-file below was tested on 32-bit and Intel 64-bit systems (please test on AMD64), giving correct results in <1 second:

Test results

@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\0" | 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.

Synetech

Posted 2010-01-15T05:28:57.957

Reputation: 63 242

6

I could not find the OSArchitecture property (as per phoebus' answer) so I would suggest using the SystemType property in ComputerSystem instead.

Running the command wmic computersystem get systemtype from a command prompt gives

C:\Windows\system32>wmic computersystem get systemtype  

SystemType x64-based PC

SPiRiTS

Posted 2010-01-15T05:28:57.957

Reputation: 61

4

Regular command line: wmic OS get OSArchitecture (IIRC)

PowerShell: (gwmi win32_computersystem).SystemType

phoebus

Posted 2010-01-15T05:28:57.957

Reputation: 3 811

1I get Invalid Query in XP. – Synetech – 2012-06-24T14:23:14.117

1

Go to Start » Run and then type cmd. Now you will be in command prompt. There you can type systeminfo and then press enter. It takes a few seconds to get all your system information. You can find the processor data too.

 Processor(s):              1 Processor(s) Installed.
                           [01]: x86 Family 15 Model 4 Stepping 10 GenuineIntel
  • x86 Family means, your processor is 32-bit.
  • x64 Family means, your processor is 64-bit.

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

Rami Reddy Mullangi

Posted 2010-01-15T05:28:57.957

Reputation: 11

2Takes a few seconds indeed! And running it again won’t help because it doesn’t cache the information. Also, the Windows updates cause the part about the architecture to quickly scroll off-screen, so unless you have a large enough buffer, you need to pipe it into more. – Synetech – 2012-09-20T05:14:52.053

1

if you are referring to windows OS, you can use vbscript with 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

user31894

Posted 2010-01-15T05:28:57.957

Reputation: 2 245

1

You can find that Information using "System Information"

Start-> Run -> winmsd.exe

Under "System Summary"/ System Type you can find the OS version

X64 -> 64 Bit
X86 -> 32 Bit

JohnT's answer in GUI ;)

ukanth

Posted 2010-01-15T05:28:57.957

Reputation: 9 930

0

Simple code I used:

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

Dion

Posted 2010-01-15T05:28:57.957

Reputation: 1