Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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.

share|improve this question

marked as duplicate by MaQleod, Ƭᴇcʜιᴇ007, Shinrai, nhinkle Aug 12 '11 at 17:57

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1  
Hmm, it's sad that systeminfo does not list this. –  Tom Wijsman Aug 11 '11 at 17:50
    
@MaQleod - I'd personally argue that just because your answer suits both, that the questions aren't exact duplicates because this one is a much more specific scenario. I don't know if your answer quite fits 'command line only' since it needs an extra utility, but if it were me I'd post it as an answer here. –  Shinrai Aug 11 '11 at 18:13
    
@MaQleod I personally wouldn't call it a duplicate since it's asking for a specifically command-line only solution. The question you linked has an accepted answer for a GUI solution. –  Ben Richards Aug 11 '11 at 18:14
1  
Thank you for the edit + answers. I chose the answer that best suited my situation. –  Negative Aug 11 '11 at 18:16
    
I ended up finding what IS an exact duplicate of this. (Linked post specifically references command-line only, and even provides my exact solution.) –  Shinrai Aug 12 '11 at 14:58
show 1 more comment

5 Answers 5

up vote 52 down vote accepted

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

share|improve this answer
    
This sounds like the solution I'd use... Now that I know of it. –  Doc Aug 11 '11 at 18:08
    
+1 good to know. –  TookTheRook Aug 11 '11 at 18:42
2  
Or to do the same thing in Powershell if you are on a W7 machine or another windows OS where you have installed PS: (gwmi win32_OperatingSystem).OSArchitecture –  EBGreen Aug 11 '11 at 19:33
    
Not working here on Windows XP. Returns Error: Invalid query. –  user606723 Aug 12 '11 at 14:51
    
Caveat: must be an administrator to run WMIC. –  Breakthrough Aug 12 '11 at 14:53
show 4 more comments

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%
share|improve this answer
    
Doesn't this show the PROCESSOR type, not the installed OS type? –  Shinrai Aug 11 '11 at 17:58
    
I don't think so, because 32-bit mode and 64-bit mode are different modes the processor could be in. A processor could be in 32-bit mode, and I don't think the OS would know inherently if it could transition into 64-bit mode. However, it's a good point, it's something that would have to be tested. As I know my brother has a 32-bit Win 7 install on a 64-bit capable processor, I'll ask him to check for me. –  Ben Richards Aug 11 '11 at 18:05
    
Yeah, I'm not sure (hence the tentative response) and unfortunately don't have anything handy to check on myself. I thought this was just a string that a given processor reported back, regardless of how it's functioning. It would be helpful to know for sure. –  Shinrai Aug 11 '11 at 18:11
2  
If you run a 32-bit OS on a 64-bit system, %PROCESSOR_ARCHITECTURE% will still be "x86". In most cases, a 64-bit OS can run 32-bit programs, but this does not work the other way around. –  bobbymcr Aug 12 '11 at 5:54
1  
up vote as echo %PROCESSOR_ARCHITECTURE% works even in sql server command shell too.where as wmic os get osarchitecture sometime's doesn't work in sql server command shell –  HDA Oct 1 '13 at 8:51
show 3 more comments

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
share|improve this answer
1  
I'd be nice if the file came with source. It's rather unnerving to download an small exe, posted to mediafire, and to run it. –  artifex Aug 12 '11 at 6:33
1  
@artifex, added source. –  MaQleod Aug 12 '11 at 6:45
    
it could be false U_U Jocking :) –  Pitto Aug 12 '11 at 8:07
    
It would be nice to know what API autoit is using internally.. –  user606723 Aug 12 '11 at 15:04
add comment

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

share|improve this answer
    
Better workaround than checking for the folder, yeah. (I don't like using a workaround, but if you're going to this is the one to use.) –  Shinrai Aug 11 '11 at 17:56
    
Very good catch... I have a batch that checks for the folder, but this would definitely be more elegant. –  WernerCD Aug 11 '11 at 19:24
add comment

What if you just check for the presence of

%SYSTEMROOT%\Program Files(x86)

or whatever it's called?

share|improve this answer
    
Not a super solution, but maybe quick and dirty works for your particular problem? –  Doc Aug 11 '11 at 17:51
    
You beat me to this solution, +1. A short form could be dir \Program *. –  Tom Wijsman Aug 11 '11 at 17:52
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.