Windows 32 (x86) or 64 (AMD64) detection in batch files
While there are a lot of ways to detect for a 64 bit version of windows. you can test for %programFiles(x86)%, but handling the output and writing the IF comparisons is messy.
In Batch files, you can easily check for architecture by using the “processor_architecture” variable. x86 versions of windows will have this set to “x86″, and x64 versions “x64″. Heres an easy example:
@echo off
IF %processor_architecture% == AMD64 echo This is a 64-bit version of windows
IF %processor_architecture% == x86 echo this is a 32-bit version of windows.
pause
This bat is not 100% reliable- returned 64-bit when i ran it on my 32-bit Office 2010 system.
This method returns the processor architecture of the shell environment currently running.
The only way to get a false positive with this method is to run the 32-bit x86 version of cmd.exe which 64 bit versions of windows keep in c:\windows\syswow64\cmd.exe. The default shell in x64 bit windows is in c:\windows\system32\cmd.exe.
I’m not familiar with how you would run a batch file from MS office, but I’m guessing that if you installed 32-bit office on a 64-bit version of windows, the shell that the 32-bit program runs would be the non-default 32-bit one.