Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need to build a batch file for Windows 7. This .bat file is just for installing an application. The issue is that I need to know if Windows 7 is 32 bits (and then run a 32 installer) or if it is a Windows 7 64 bits (then run the 64 bits installer). Which command can I use in a batch file to know if Windows 7 is 32 or 64 bits?

Thanks in advance!!!

share|improve this question
I swear I've seen this before... – Hello71 Aug 20 '10 at 17:26

in a 64bit environment you will have an environment variable called


in a 32bit environment you do not have that variable. so you could check with

if defined ProgramFiles(x86) (
   REM do stuff for 64bit here
) else (
   REM do stuff for 32bit here
share|improve this answer

If you don't want to use a temp txt file use a pipe:

Set RegQry=HKLM\Hardware\Description\System\CentralProcessor\0
REG.exe Query %RegQry%  | Find /i "x86" 
If %ERRORLEVEL% == 0 (
    GOTO X86
) ELSE (
    GOTO X64


Commands here



commands here

share|improve this answer

When you are using DEFINED, you must not enclose the variable name with % signs:

if defined ProgramFiles(x86) (
   :: do stuff for 64bit here
) else (
   :: do stuff for 32bit here
share|improve this answer

You may use the environment variable PROCESSOR_ARCHITECTURE to determine whether the process itself is running as 32-bit or 64-bit. The value is either AMD64 or x86.

You need to be careful though. If your batch file is being run from the 32-bit version of CMD.EXE (in \Windows\SysWOW64) this variable would be set to "x86", while it would be "AMD64" if from the CMD.EXE in \Windows\System32 on a 64-bit version of Windows.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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