From ae853df86b5af352930ed0a84abcc1338196b8a4 Mon Sep 17 00:00:00 2001 From: Calyx Hikari Date: Mon, 4 Aug 2025 10:14:59 +0800 Subject: [PATCH] Update install routine --- 32 | 50 +++++++++++++++++++++++----------------- 64 | 53 +++++++++++++++++++++++------------------- dx | 4 ++++ index.html | 67 +++++++++++++++++++++++++++++++++++------------------- 4 files changed, 106 insertions(+), 68 deletions(-) diff --git a/32 b/32 index 11c8fd1..011081a 100644 --- a/32 +++ b/32 @@ -11,6 +11,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 } @@ -93,29 +97,33 @@ function Main { @{ Name = "vcredist_2015-2022_x86.exe"; Url = "https://aka.ms/vs/17/release/vc_redist.x86.exe"; Year = "2015-2022" } ) + $ariaListPath = Join-Path $tempDir "fileList.txt" + # --- Download everything up front --- foreach ($item in $downloads) { - $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 --- diff --git a/64 b/64 index 6bbd653..0b97b30 100644 --- a/64 +++ b/64 @@ -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 --- diff --git a/dx b/dx index bc8c3d3..fd2edeb 100644 --- a/dx +++ b/dx @@ -11,6 +11,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 } diff --git a/index.html b/index.html index 8e7c9bf..604da58 100644 --- a/index.html +++ b/index.html @@ -10,11 +10,16 @@ function Main { } $procArch = $Env:PROCESSOR_ARCHITECTURE + $isServer = (Get-CimInstance Win32_OperatingSystem).ProductType -ne 1 $buildVersion = (Get-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion').CurrentBuild if ($procArch -eq 'ARM') { 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 } @@ -40,6 +45,13 @@ function Main { } } + if ($isServer) { + Write-Warning "Windows Server detected, DirectX will not be installed. To install it anyway, execute following command:" + Write-Host "irm https://get.msvc.win/dx | iex" + Write-Host "This script will continue in 10 seconds..." + Start-Sleep -Seconds 10 + } + # --- Elevated section --- New-Item -Path $flagPath -ItemType File -Force | Out-Null Write-Host "Running with elevated privileges..." @@ -110,32 +122,39 @@ 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 -ne "AMD64" -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 + if ($item.Name -Match "directx" -and $isServer) { + continue } + $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 --- @@ -172,9 +191,11 @@ function Main { } # --- Install DirectX --- - Write-Host "Installing DirectX..." - Start-Process -FilePath "$tempDir\directx_redist.exe" -ArgumentList "/Q /T:`"$tempDir`"" -Wait - Start-Process -FilePath "$tempDir\DXSETUP.exe" -ArgumentList "/silent" -Wait + if (-not $isServer) { + Write-Host "Installing DirectX..." + Start-Process -FilePath "$tempDir\directx_redist.exe" -ArgumentList "/Q /T:`"$tempDir`"" -Wait + Start-Process -FilePath "$tempDir\DXSETUP.exe" -ArgumentList "/silent" -Wait + } # --- Install VC++ Redistributables --- foreach ($item in $downloads | Where-Object { $_.Name -like "vcredist*" }) {