Search code examples
x8664-bitautoitcpu-architecture

Determine Windows as 32- or 64bit


This is the code I have so far:

#include <MsgBoxConstants.au3>
If FileExists(@HomeDrive & "Program Files (x86)") Then
   $arc = 64
Else
   $arc = 32
EndIf
MsgBox("Hello", "Bit", "The computer that the program is been run on is a " & $arc & "bit one.")

It will say my computer is 32bit when it is 64. So I had a look at the path and made new code:

#include <MsgBoxConstants.au3>
If FileExists(@HomeDrive & "Program Files (x86)") Then
   $arc = 64
Else
   $arc = 32
EndIf
$path = @HomeDrive & "\Program Files (x86)"
MsgBox("Hello", $path, "The computer that the program is been run on is a " & $arc & "bit one.")

This shows the path and seems to be OK. Where am I going wrong?


Solution

  • You need to read the @OSArch macro.

    Returns one of the following: "X86", "IA64", "X64" - this is the architecture type of the currently running operating system.