How do I run exe based on Windows bit size?

Posted on


I have two .exe files, and I would like to create one program that will be able to run one of them based on the Windows bit size (ie, run program1.exe if 64-bit and run program2.exe if 32-bit). Does anyone know where I should start looking?


You could use a simple windows Powershell script as your launcher.

Here’s how you can tell your architechure from PS:

The idea is to check how many bytes long the IntPtr structure is. 4=> 32b, 8 => 64b.

If you really want an exe, in DotNet, you could use this check to determine if its 64b:

BOOL Is64BitWindows() {
 #if defined(_WIN64)
  return TRUE;  // 64-bit programs run only on Win64
 #elif defined(_WIN32)
  // 32-bit programs run on both 32-bit and 64-bit Windows
  // so must sniff
  BOOL f64 = FALSE;
  return IsWow64Process(GetCurrentProcess(), &f64) && f64;
  return FALSE; // Win64 does not support Win16

more info here:

You can always check the %programfiles(x86)% environment variable. If it’s a Windows 64-bit machine it will return the path to “Program Files (x86)”, if it’s not 64-bit it won’t be defined and will just return “%programfiles(x86)%”.

You can check this with a batch, PS, .Net, or whatever you’d like. 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *