```powershell param ( [string]$Program, [string]$InstallDir = "F:\PackageManagerInstalls\WinGet\", [string]$WingetExtraOptions = '' ) $BaseInstallDir = (Get-ItemProperty -Path $InstallDir).FullName.TrimEnd('\') $TargetInstallDir = "$($BaseInstallDir)\$($Program)" function Write-WithColor { param ( $BGColor = 'White', $FGColor = 'Black', $Message ) $ConsolePreviousBGColour = (Get-Host).UI.RawUI.BackgroundColor $ConsolePreviousFGColour = (Get-Host).UI.RawUI.ForegroundColor $WindowWidth = (Get-Host).UI.RawUI.WindowSize.Width (Get-Host).UI.RawUI.BackgroundColor=$BGColor (Get-Host).UI.RawUI.ForegroundColor=$FGColor Write-Host $message.PadRight($WindowWidth) (Get-Host).UI.RawUI.BackgroundColor=$ConsolePreviousBGColour (Get-Host).UI.RawUI.ForegroundColor=$ConsolePreviousFGColour } function Exit-ReturnError { param ( [int]$code = 5, [string]$message ) Write-WithColor -FGColor 'White' -BGColor 'Red' -Message "An error has occurred." Write-WithColor -FGColor 'White' -BGColor 'DarkRed' -Message $message exit $code } if (!$program) { Exit-ReturnError -Message 'A program to install must be provided in -Program ' -Code 5 } $OverrideString = "MSI_TARGETDIR=$($TargetInstallDir) INSTALLDIR=$($TargetInstallDir) INSTALLPATH=$($TargetInstallDir) INSTALLFOLDER=$($TargetInstallDir) INSTALLLOCATION=$($TargetInstallDir) APPDIR=$($TargetInstallDir) APPLICATIONFOLDER=$($TargetInstallDir) TARGETDIR=$($TargetInstallDir)" winget install $($Program) -l $TargetInstallDir --override $OverrideString $WingetExtraOptions ```