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

83

26

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

Posted 2011-08-11T17:44:11.570

Reputation: 1 239

Question was closed 2011-08-12T17:57:43.457

Use : uname -a for linux system , Did u see how it is so simple with linux ? if so , delete windows and install linux – Abdennour TOUMI – 2014-06-26T10:59:00.543

1Hmm, it's sad that systeminfo does not list this. – Tamara Wijsman – 2011-08-11T17:50:25.977

@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 – 2011-08-11T18:13:55.277

@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 – 2011-08-11T18:14:14.777

1Thank you for the edit + answers. I chose the answer that best suited my situation. – Negative – 2011-08-11T18:16:59.987

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 – 2011-08-12T14:58:19.140

Answers

128

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

Posted 2011-08-11T17:44:11.570

Reputation: 18 051

If the output is too long you can optionally find it via wmic os | findstr "64-bit" or wmic os | findstr "32-bit" – fohrums – 2018-08-31T03:23:13.100

This sounds like the solution I'd use... Now that I know of it. – James T Snell – 2011-08-11T18:08:51.820

2Or 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 – 2011-08-11T19:33:45.830

2Not working here on Windows XP. Returns Error: Invalid query. – user606723 – 2011-08-12T14:51:08.850

1Caveat: must be an administrator to run WMIC. – Breakthrough – 2011-08-12T14:53:52.733

@user606723 - I don't have an XP install handy to test on, but I didn't think the WMI hooks had changed that much. OP did not specify an OS, to be fair, but I'll have to test this myself. – Shinrai – 2011-08-12T14:56:36.253

@Breakthrough - You're right, I should be explicit about this. – Shinrai – 2011-08-12T14:56:48.967

wmic is not recognized as an internal or external command.... – Pacerier – 2013-08-19T14:00:57.910

58

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

Ben Richards

Posted 2011-08-11T17:44:11.570

Reputation: 11 662

+1 as this solution does not require admin rights, whereas the accepted answer does – Kidburla – 2015-06-29T16:35:23.113

1Doesn't this show the PROCESSOR type, not the installed OS type? – Shinrai – 2011-08-11T17:58:24.643

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 – 2011-08-11T18:05:19.813

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 – 2011-08-11T18:11:04.877

4If 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 – 2011-08-12T05:54:28.433

@bobbymcr - Thanks for confirmation, in that case I retract my objection. – Shinrai – 2011-08-12T13:10:41.373

This is the by far the best answer. – user606723 – 2011-08-12T15:05:11.003

2up 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 – Durai Amuthan.H – 2013-10-01T08:51:32.357

This is exactly what I was looking for on my Windows XP machine, will greatly help me with scripting projects – root – 2013-10-30T14:25:33.733

8

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

Posted 2011-08-11T17:44:11.570

Reputation: 32 927

1You can also compare the %PROGRAMFILES(x86)% and %PROGRAMFILES% variables to see if the cmd has been started in 32bit or 64bit mode. (Because on a 64 bit windows you can still run a 32bit cmd.) Example:

IF %PROGRAMFILES(x86)% == %PROGRAMFILES% => 32bit cmd (that is running on a 64 bit windows.....)

IF %PROGRAMFILES(x86)% <> %PROGRAMFILES% => 64bit cmd. – Sam Hasler – 2016-08-22T09:58:24.547

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 – 2011-08-11T17:56:15.597

Very good catch... I have a batch that checks for the folder, but this would definitely be more elegant. – WernerCD – 2011-08-11T19:24:12.600

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

Posted 2011-08-11T17:44:11.570

Reputation: 12 560

1I'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 – 2011-08-12T06:33:53.610

1@artifex, added source. – MaQleod – 2011-08-12T06:45:55.263

it could be false U_U

Jocking :) – Pitto – 2011-08-12T08:07:10.627

It would be nice to know what API autoit is using internally.. – user606723 – 2011-08-12T15:04:13.233

4

What if you just check for the presence of

%SYSTEMROOT%\Program Files(x86)

or whatever it's called?

James T Snell

Posted 2011-08-11T17:44:11.570

Reputation: 5 726

Not a super solution, but maybe quick and dirty works for your particular problem? – James T Snell – 2011-08-11T17:51:25.260

You beat me to this solution, +1. A short form could be dir \Program *. – Tamara Wijsman – 2011-08-11T17:52:30.590