Why read this post?

  • Do you ever need to know the Windows O/S architecture of a remote device when running a job across lots of devices?
  • This post tells you how to accommodate both 32-bit and 64-bit in a single job.

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.

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</p>
<p style="margin: 0in; font-family: Calibri; font-size: 11pt;"></p>
<p style="margin: 0in; font-family: Calibri; font-size: 11pt;">IF EXIST "%programfiles(x86)%" (GOTO 64-Bit) ELSE (GOTO 32-Bit)</p>
<p style="margin: 0in; font-family: Calibri; font-size: 11pt;"></p>
<p style="margin: 0in; font-family: Calibri; font-size: 11pt;">:32-Bit</p>
<p style="margin: 0in; font-family: Calibri; font-size: 11pt;">ECHO 32-Bit O/S detected</p>
<p style="margin: 0in; font-family: Calibri; font-size: 11pt;">GOTO END</p>
<p style="margin: 0in; font-family: Calibri; font-size: 11pt;"></p>
<p style="margin: 0in; font-family: Calibri; font-size: 11pt;">:64-Bit</p>
<p style="margin: 0in; font-family: Calibri; font-size: 11pt;">ECHO 64-Bit O/S detected</p>
<p style="margin: 0in; font-family: Calibri; font-size: 11pt;">GOTO END</p>
<p style="margin: 0in; font-family: Calibri; font-size: 11pt;"></p>
<p style="margin: 0in; font-family: Calibri; font-size: 11pt;">: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.