@@ -104,7 +104,7 @@ function Write-Log ($LogMsg, $LogColor = "White") {
104104# Get WinGet Location Function
105105function Get-WingetCmd {
106106 # Get WinGet Path (if admin context)
107- $ResolveWingetPath = Resolve-Path " $env: ProgramFiles \WindowsApps\Microsoft.DesktopAppInstaller_*_x64__8wekyb3d8bbwe " | Sort-Object { [version ]($_.Path -replace ' ^[^\d]+_((\d+\.)*\d+)_.*' , ' $1' ) }
107+ $ResolveWingetPath = Resolve-Path " $env: ProgramFiles \WindowsApps\Microsoft.DesktopAppInstaller_*_*__8wekyb3d8bbwe " | Sort-Object { [version ]($_.Path -replace ' ^[^\d]+_((\d+\.)*\d+)_.*' , ' $1' ) }
108108 if ($ResolveWingetPath ) {
109109 # If multiple versions, pick last one
110110 $WingetPath = $ResolveWingetPath [-1 ].Path
@@ -129,17 +129,12 @@ function Get-WingetCmd {
129129function Add-ScopeMachine {
130130 # Get Settings path for system or current user
131131 if ([System.Security.Principal.WindowsIdentity ]::GetCurrent().IsSystem) {
132- if ([Environment ]::Is64BitProcess -ne [Environment ]::Is64BitOperatingSystem) {
133- $SettingsPath = " $Env: windir \sysnative\config\systemprofile\AppData\Local\Microsoft\WinGet\Settings\settings.json"
134- }
135- else {
136- $SettingsPath = " $Env: windir \System32\config\systemprofile\AppData\Local\Microsoft\WinGet\Settings\settings.json"
137- }
132+ $SettingsPath = " $Env: windir \System32\config\systemprofile\AppData\Local\Microsoft\WinGet\Settings\settings.json"
138133 }
139134 else {
140135 $SettingsPath = " $env: LOCALAPPDATA \Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\settings.json"
141136 }
142-
137+
143138 # Check if setting file exist, if not create it
144139 if (Test-Path $SettingsPath ) {
145140 $ConfigFile = Get-Content - Path $SettingsPath | Where-Object { $_ -notmatch ' //' } | ConvertFrom-Json
@@ -228,7 +223,7 @@ function Install-App ($AppID, $AppArgs) {
228223 $WingetArgs = " install --id $AppID -e --accept-package-agreements --accept-source-agreements -h $AppArgs " -split " "
229224 Write-Log " -> Running: `" $Winget `" $WingetArgs "
230225 & " $Winget " $WingetArgs | Tee-Object - file $LogFile - Append
231-
226+
232227 # Check if install is ok
233228 $IsInstalled = Confirm-Install $AppID
234229 if ($IsInstalled ) {
@@ -345,6 +340,14 @@ function Remove-WAUMods ($AppID) {
345340
346341<# MAIN #>
347342
343+ # If running as a 32-bit process on an x64 system, re-launch as a 64-bit process
344+ if (" $env: PROCESSOR_ARCHITEW6432 " -ne " ARM64" ) {
345+ if (Test-Path " $ ( $env: WINDIR ) \SysNative\WindowsPowerShell\v1.0\powershell.exe" ) {
346+ Start-Process " $ ( $env: WINDIR ) \SysNative\WindowsPowerShell\v1.0\powershell.exe" - Wait - NoNewWindow - ArgumentList " -NoProfile -ExecutionPolicy Bypass -Command $ ( $MyInvocation.line ) "
347+ Exit $lastexitcode
348+ }
349+ }
350+
348351Write-Host " `n "
349352Write-Host " `t 888 888 d8b .d8888b. d8b" - ForegroundColor Cyan
350353Write-Host " `t 888 o 888 Y8P d88P Y88b Y8P" - ForegroundColor Cyan
0 commit comments