Update install routine

This commit is contained in:
Calyx Hikari 2025-08-04 10:14:59 +08:00
parent a7ffeac9db
commit ae853df86b
4 changed files with 106 additions and 68 deletions

53
64
View file

@ -19,6 +19,10 @@ function Main {
Write-Warning "This script does not support Windows RT. Exiting..."
return 1
}
elseif ($procArch -eq 'ia64') {
Write-Warning "This script does not support Itanium. Exiting..."
return 1
}
$flagPath = "$env:TEMP\elevation_success.flag"
if (Test-Path $flagPath) { Remove-Item $flagPath -ErrorAction SilentlyContinue }
@ -111,32 +115,33 @@ function Main {
$downloads += @{ Name = "vcredist_2015-2022_arm64.exe"; Url = "https://aka.ms/vs/17/release/vc_redist.arm64.exe"; Year = "2012-2022" }
}
$ariaListPath = Join-Path $tempDir "fileList.txt"
# --- Download everything up front ---
foreach ($item in $downloads) {
if ($item.Name -Match "x64" -and $procArch -eq 'ARM64' -and $buildVersion -lt 22000) {
continue
}
$outFile = Join-Path $tempDir $item.Name
Write-Host "Downloading $($item.Name)..."
$argumentList = @(
"--dir=`"$($outFile | Split-Path)`"",
"--out=`"$(Split-Path -Leaf $outFile)`"",
"--allow-overwrite=true",
"--retry-wait=5",
"--max-connection-per-server=8",
"--split=8",
"--min-split-size=1M",
"`"$($item.Url)`""
)
if (![string]::IsNullOrEmpty($regionalWorkaround)) {
$argumentList += $regionalWorkaround
}
$proc = Start-Process -FilePath $aria2Exe -ArgumentList $argumentList -NoNewWindow -PassThru -Wait
if ($proc.ExitCode -ne 0) {
Write-Warning "aria2c failed (exit code $($proc.ExitCode)). Retrying with --check-certificate=false..."
$argsRetry = $argumentList + "--check-certificate=false"
Start-Process -FilePath $aria2Exe -ArgumentList $argsRetry -NoNewWindow -Wait
}
$line = "$($item.Url)`n out=$($item.Name)"
Add-Content -Path $ariaListPath -Value $line
}
Write-Host "Downloading files..."
$argumentList = @(
"--dir=`"$($outFile | Split-Path)`"",
"--out=`"$(Split-Path -Leaf $outFile)`"",
"--allow-overwrite=true",
"--retry-wait=5",
"--max-connection-per-server=8",
"--split=8",
"--min-split-size=1M",
"-i `"$ariaListPath`""
)
if (![string]::IsNullOrEmpty($regionalWorkaround)) {
$argumentList += $regionalWorkaround
}
$proc = Start-Process -FilePath $aria2Exe -ArgumentList $argumentList -NoNewWindow -PassThru -Wait
if ($proc.ExitCode -ne 0) {
Write-Warning "aria2c failed (exit code $($proc.ExitCode)). Retrying with --check-certificate=false..."
$argsRetry = $argumentList + "--check-certificate=false"
Start-Process -FilePath $aria2Exe -ArgumentList $argsRetry -NoNewWindow -Wait
}
# --- Check Signature ---