Compare commits

...

2 Commits

Author SHA1 Message Date
52de4690ab Update start.ps1 (#3223)
- use join method to parse $argList
- use $PSCommandPath instead of $MyInvocation.MyCommand.Path
- use ScriptBlock method to create request for latest winutil.ps1 with join $argList 
- condition for $processCmd because in case when wt.exe is not available, there was double/redundant declaration of shell which lead to code mishmash (incorrect interpretation of quotes from Start-Process ArgumentList parameters 
- changes in quotes and escape characters because command where not interpreted correctly in all possible cases of $powershellCmd and $processCmd
2025-03-05 12:15:13 -06:00
ef97a8da24 [WinGet] Fix install loop (#3235)
Only this parameter was missing
2025-03-05 12:13:39 -06:00
2 changed files with 14 additions and 8 deletions

View File

@ -56,7 +56,7 @@ function Test-WinUtilPackageManager {
# Check if Winget's Version is too old. # Check if Winget's Version is too old.
$wingetCurrentVersion = [System.Version]::Parse($wingetVersion.Trim('v')) $wingetCurrentVersion = [System.Version]::Parse($wingetVersion.Trim('v'))
# Grabs the latest release of Winget from the Github API for version check process. # Grabs the latest release of Winget from the Github API for version check process.
$response = winget search -e Microsoft.AppInstaller $response = winget search -e Microsoft.AppInstaller --accept-source-agreements
$wingetLatestVersion = ($response | Select-String -Pattern '\d+\.\d+\.\d+\.\d+').Matches.Value $wingetLatestVersion = ($response | Select-String -Pattern '\d+\.\d+\.\d+\.\d+').Matches.Value
Write-Host "Latest Search Version: $wingetLatestVersion" -ForegroundColor White Write-Host "Latest Search Version: $wingetLatestVersion" -ForegroundColor White
Write-Host "Current Installed Version: $wingetCurrentVersion" -ForegroundColor White Write-Host "Current Installed Version: $wingetCurrentVersion" -ForegroundColor White

View File

@ -54,21 +54,27 @@ if (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]:
$PSBoundParameters.GetEnumerator() | ForEach-Object { $PSBoundParameters.GetEnumerator() | ForEach-Object {
$argList += if ($_.Value -is [switch] -and $_.Value) { $argList += if ($_.Value -is [switch] -and $_.Value) {
"-$($_.Key)" "-$($_.Key)"
} elseif ($_.Value -is [array]) {
"-$($_.Key) $($_.Value -join ',')"
} elseif ($_.Value) { } elseif ($_.Value) {
"-$($_.Key) `"$($_.Value)`"" "-$($_.Key) '$($_.Value)'"
} }
} }
$script = if ($MyInvocation.MyCommand.Path) { $script = if ($PSCommandPath) {
"& { & '$($MyInvocation.MyCommand.Path)' $argList }" "& { & `'$($PSCommandPath)`' $($argList -join ' ') }"
} else { } else {
"iex '& { $(irm https://github.com/ChrisTitusTech/winutil/releases/latest/download/winutil.ps1) } $argList'" "&([ScriptBlock]::Create((irm https://github.com/ChrisTitusTech/winutil/releases/latest/download/winutil.ps1))) $($argList -join ' ')"
} }
$powershellcmd = if (Get-Command pwsh -ErrorAction SilentlyContinue) { "pwsh" } else { "powershell" } $powershellCmd = if (Get-Command pwsh -ErrorAction SilentlyContinue) { "pwsh" } else { "powershell" }
$processCmd = if (Get-Command wt.exe -ErrorAction SilentlyContinue) { "wt.exe" } else { $powershellcmd } $processCmd = if (Get-Command wt.exe -ErrorAction SilentlyContinue) { "wt.exe" } else { "$powershellCmd" }
Start-Process $processCmd -ArgumentList "$powershellcmd -ExecutionPolicy Bypass -NoProfile -Command $script" -Verb RunAs if ($processCmd -eq "wt.exe") {
Start-Process $processCmd -ArgumentList "$powershellCmd -ExecutionPolicy Bypass -NoProfile -Command `"$script`"" -Verb RunAs
} else {
Start-Process $processCmd -ArgumentList "-ExecutionPolicy Bypass -NoProfile -Command `"$script`"" -Verb RunAs
}
break break
} }