From 2ab3c169e992ed83dd84dd7255e899b087320493 Mon Sep 17 00:00:00 2001 From: Calyx Hikari Date: Sun, 29 Jun 2025 14:39:34 +0800 Subject: [PATCH] Fix null argument issue --- 32 | 9 ++++++--- 64 | 9 ++++++--- dx | 9 ++++++--- index.html | 9 ++++++--- 4 files changed, 24 insertions(+), 12 deletions(-) diff --git a/32 b/32 index 030b299..69fcfe9 100644 --- a/32 +++ b/32 @@ -91,7 +91,7 @@ function Main { foreach ($item in $downloads) { $outFile = Join-Path $tempDir $item.Name Write-Host "Downloading $($item.Name)..." - Start-Process -FilePath $aria2Exe -ArgumentList @( + $argumentList = @( "--dir=`"$($outFile | Split-Path)`"", "--out=`"$(Split-Path -Leaf $outFile)`"", "--allow-overwrite=true", @@ -99,9 +99,12 @@ function Main { "--max-connection-per-server=8", "--split=8", "--min-split-size=1M", - "$regionalWorkaround", "`"$($item.Url)`"" - ) -NoNewWindow -Wait + ) + if (![string]::IsNullOrEmpty($regionalWorkaround)) { + $argumentList += $regionalWorkaround + } + Start-Process -FilePath $aria2Exe -ArgumentList $argumentList -NoNewWindow -Wait } # --- Install DirectX --- diff --git a/64 b/64 index 70093f8..2ae1365 100644 --- a/64 +++ b/64 @@ -102,7 +102,7 @@ function Main { foreach ($item in $downloads) { $outFile = Join-Path $tempDir $item.Name Write-Host "Downloading $($item.Name)..." - Start-Process -FilePath $aria2Exe -ArgumentList @( + $argumentList = @( "--dir=`"$($outFile | Split-Path)`"", "--out=`"$(Split-Path -Leaf $outFile)`"", "--allow-overwrite=true", @@ -110,9 +110,12 @@ function Main { "--max-connection-per-server=8", "--split=8", "--min-split-size=1M", - "$regionalWorkaround", "`"$($item.Url)`"" - ) -NoNewWindow -Wait + ) + if (![string]::IsNullOrEmpty($regionalWorkaround)) { + $argumentList += $regionalWorkaround + } + Start-Process -FilePath $aria2Exe -ArgumentList $argumentList -NoNewWindow -Wait } # --- Install VC++ Redistributables --- diff --git a/dx b/dx index ccc215e..d360a40 100644 --- a/dx +++ b/dx @@ -88,7 +88,7 @@ function Main { foreach ($item in $downloads) { $outFile = Join-Path $tempDir $item.Name Write-Host "Downloading $($item.Name)..." - Start-Process -FilePath $aria2Exe -ArgumentList @( + $argumentList = @( "--dir=`"$($outFile | Split-Path)`"", "--out=`"$(Split-Path -Leaf $outFile)`"", "--allow-overwrite=true", @@ -96,9 +96,12 @@ function Main { "--max-connection-per-server=8", "--split=8", "--min-split-size=1M", - "$regionalWorkaround", "`"$($item.Url)`"" - ) -NoNewWindow -Wait + ) + if (![string]::IsNullOrEmpty($regionalWorkaround)) { + $argumentList += $regionalWorkaround + } + Start-Process -FilePath $aria2Exe -ArgumentList $argumentList -NoNewWindow -Wait } # --- Install DirectX --- diff --git a/index.html b/index.html index 036b70d..4588940 100644 --- a/index.html +++ b/index.html @@ -107,7 +107,7 @@ function Main { } $outFile = Join-Path $tempDir $item.Name Write-Host "Downloading $($item.Name)..." - Start-Process -FilePath $aria2Exe -ArgumentList @( + $argumentList = @( "--dir=`"$($outFile | Split-Path)`"", "--out=`"$(Split-Path -Leaf $outFile)`"", "--allow-overwrite=true", @@ -115,9 +115,12 @@ function Main { "--max-connection-per-server=8", "--split=8", "--min-split-size=1M", - "$regionalWorkaround", "`"$($item.Url)`"" - ) -NoNewWindow -Wait + ) + if (![string]::IsNullOrEmpty($regionalWorkaround)) { + $argumentList += $regionalWorkaround + } + Start-Process -FilePath $aria2Exe -ArgumentList $argumentList -NoNewWindow -Wait } # --- Install DirectX ---