How do I determine if my Windows is 32-bit or 64-bit using a command? [duplicate]

Solution 1:

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".

Solution 2:

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

Solution 3:

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).

Solution 4:

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

Solution 5:

What if you just check for the presence of

%SYSTEMROOT%\Program Files(x86)

or whatever it's called?