98

Possible Duplicates:
How to tell if a computer has a 64-bit CPU or OS
Detect Windows Server version 32/64-bit in CLI
OS version: 32-bit or 64-bit?

How do I determine if my Windows system is 32-bit or 64-bit from the commandline?

I want to know the bitness of the operating system, not the hardware.

This question applies strictly to command line only, I don't want any GUI solutions.

Negative
  • 1,449

5 Answers5

149

From an elevated command prompt, type wmic os get osarchitecture. The output is pretty obvious, I think - it'll return either "32-bit" or "64-bit".

Shinrai
  • 18,876
70

The systeminfo console program will show this. You will want to look for the "System Type:" line. For 32-bit systems, it will say "x86-based PC'. For 64-bit systems, it will say "x64-based PC".

Or, for a quicker method, you can simply check the PROCESSOR_ARCHITECTURE environment variable. 64-bit systems will say AMD64 and 32-bit systems should say "x86". To check this you can simply echo it out:

echo %PROCESSOR_ARCHITECTURE%

David Wang over at MSDN Blogs expands upon this HOWTO: Detect Process Bitness

Glorfindel
  • 4,158
Ben Richards
  • 12,917
10

You can check if the %PROGRAMFILES(x86)% environment variable is declared. On 32-bit systems, it will not be defined (only %PROGRAMFILES% will be). This is also safer then just checking if the Program Files (x86) directory exists, since it can be moved (or even deleted).

Breakthrough
  • 34,847
8

I wrote a simple command line application that will tell you whether your processor and your OS are either 64-bit or 32-bit.

Readout example:

C:\bitchecker
The CPU is 64-bit and the OS is 32-bit

Per request, here is the source, compiled using CLI option, written in AutoIt.

If @CPUARCH = "x86" Then
    $CPUARCH = "32-bit"
Else
    $CPUARCH = "64-bit"
EndIf

If @OSARCH = "x86" Then
    $OSARCH = "32-bit"
Else
    $OSARCH = "64-bit"
EndIf

ConsoleWrite("The CPU is " & $CPUARCH & " and the OS is " & $OSARCH)

And here is an example if you want switches for CPU (-c) and OS (-o):

Dim $CPUARCH, $OSARCH

If @CPUARCH = "x86" Then
    $CPUARCH = "32-bit"
Else
    $CPUARCH = "64-bit"
EndIf

If @OSARCH = "x86" Then
    $OSARCH = "32-bit"
Else
    $OSARCH = "64-bit"
EndIf

If $CmdLine[0] = 0 Then
    ConsoleWrite("The CPU is " & $CPUARCH & " and the OS is " & $OSARCH)
Else
    Select
        Case $CmdLine[1] = "-c"
            ConsoleWrite($CPUARCH)
        Case $CmdLine[1] = "-o"
            ConsoleWrite($OSARCH)
        Case Else
            ConsoleWrite("The CPU is " & $CPUARCH & " and the OS is " & $OSARCH)
    EndSelect
EndIf
MaQleod
  • 13,258
4

What if you just check for the presence of

%SYSTEMROOT%\Program Files(x86)

or whatever it's called?