Why read this post?
Here’s a neat little trick to determine the Windows operating system architecture that is present on the remote device. Sometimes you may have two different installers for 32-Bit and 64-Bit or need to determine which version you are dealing with for some other reason.
A simple way of doing this is reliant on the fact that 64-Bit operating systems have an environment variable of %programfiles(x86)% whereas 32-Bit versions don’t. Therefore you can do a quick check to see if this variable path is present and redirect the flow of your batch file accordingly using batch file labels.
The following script is a simple illustration of this and will output a message to show either 64-Bit or 32-Bit depending on what version of Windows you are dealing with. Note that this is nothing to do with the processor architecture, only the version of Windows.
@ECHO OFF IF EXIST "%programfiles(x86)%" (GOTO 64-Bit) ELSE (GOTO 32-Bit) :32-Bit ECHO 32-Bit O/S detected GOTO END :64-Bit ECHO 64-Bit O/S detected GOTO END :END
This can be easily modified to call one of two different installation files for example allowing you to use the same script on both 32-Bit and 64-Bit devices.