Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

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

On Windows, like:

is64 abc.exe  


is32 def.exe  

While abc.exe is compiled 64-bit and def.exe is 32-bit on Windows.

share|improve this question

migrated from Aug 31 '12 at 9:40

This question came from our site for professional and enthusiast programmers.

Not that I know of but creating an utility that reads the PE header of a binary shouldn't be overwhelmingly difficult. Studying the PE format right now, will answer if I figure it out. – Esa Lakaniemi Aug 31 '12 at 9:49
'Kay, figured it out and answered with a package of command line tools doing what you asked. I think. – Esa Lakaniemi Aug 31 '12 at 12:15
up vote 5 down vote accepted

Is there a command line tool to check 32-bit or 64-bit of an exe?


c:\Program Files (x86)\GnuWin32\bin>file file.exe
file.exe; PE32 executable for MS Windows (console) Intel 80386 32-bit

c:\Program Files (x86)\GnuWin32\bin>cd ..\..\evernote\evernote   
c:\Program Files (x86)\Evernote\Evernote>file evernote.exe
evernote.exe; PE32 executable for MS Windows (GUI) Intel 80386 32-bit

c:\Program Files (x86)\Evernote\Evernote>cd c:\Program Files\Internet Explorer    
c:\Program Files\Internet Explorer>file iexplore.exe
iexplore.exe; PE32+ executable for MS Windows (GUI) Mono/.Net assembly

The PE32 format stands for Portable Executable 32-bit, while PE32+ is Portable Executable 64-bit format.



is64 abc.exe

Not exactly like that.

You can use the -b option to exclude the filename from the output, then you just need some command-line kung fu to extract the first word (PE32 or PE32+) compare it with PE32+ and use that in your ìf` statement.

share|improve this answer

I wrote a pair of programs strictly doing what you asked for (With the addition of error messages on errors et cetera.) (And actually, it's one program with a define that changes its behaviour to be perfectly accurate, but that doesn't matter.)

You can find them on my Dropbox, here. Source code is included in the package but you can discard it if it's unneeded. It's basically only included in case you don't trust my binaries.

Example of use:

>is32 C:\Windows\System32\taskmgr.exe

>is64 C:\Windows\System32\taskmgr.exe

Basically, the program works by first memory-mapping the binary, then locating the PE header and finally simply comparing the Machine field to the value for whichever architecture you ask for. Essentially a very simple process.

share|improve this answer
While file is probably the better solution, the +1 is because this kind of help should be rewarded. – Ben Oct 3 '14 at 10:10
$  file access-client-win32.exe 

access-client-win32.exe: PE32 executable for MS Windows (console) Intel 80386 32-bit

$ file access-client-win64.exe

access-client-win64.exe: PE32+ executable for MS Windows (console) Mono/.Net assembly

win32.exe -> PE32

win64.exe -> PE32+

ps: PE -> Portable Executable

share|improve this answer
Remember to properly format your answer. Use a right angle bracket > before each line of a block quote, and indent code blocks with four spaces. – bwDraco Dec 10 '14 at 7:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .