From 9e820f3d0c78f2fa5255203001c2538b3b9cee04 Mon Sep 17 00:00:00 2001 From: dtgm Date: Fri, 24 Jun 2016 12:40:48 -0600 Subject: [PATCH] (GH-828) Return OS bit width, not process Get-OSArchitectureWidth returns the current process bit-width regardless of OS arch. So in 32-bit powershell running on 64-bit windows, it returns 32 because [System.IntPtr]::Size returns 4 in 32-bit process regardless of OS architecture (32 or 64). This fix returns actual OS bit width. --- .../helpers/functions/Get-OSArchitectureWidth.ps1 | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/chocolatey.resources/helpers/functions/Get-OSArchitectureWidth.ps1 b/src/chocolatey.resources/helpers/functions/Get-OSArchitectureWidth.ps1 index b54fed6a39..7e88fb7e8b 100644 --- a/src/chocolatey.resources/helpers/functions/Get-OSArchitectureWidth.ps1 +++ b/src/chocolatey.resources/helpers/functions/Get-OSArchitectureWidth.ps1 @@ -45,7 +45,9 @@ param( Write-Debug "Running 'Get-OSArchitectureWidth'" $bits = 64 - if ([System.IntPtr]::Size -eq 4) { + if (([System.IntPtr]::Size -eq 4) -and (Test-Path env:\PROCESSOR_ARCHITEW6432)) { + $bits = 64 + } elseif ([System.IntPtr]::Size -eq 4) { $bits = 32 }