Add vstor redist and signature check

This commit is contained in:
Calyx Hikari 2025-07-01 11:21:47 +08:00
parent cabd291242
commit 34551e59f2
4 changed files with 107 additions and 0 deletions

28
32
View file

@ -78,6 +78,7 @@ function Main {
# --- Define all downloads ---
$downloads = @(
@{ Name = "vstor_redist.txt"; Url = "https://download.microsoft.com/download/8/6/4/8641e164-7796-4b34-81c7-30d24a5bd533/vstor_redist.exe" },
@{ Name = "vcredist_2005_x86.exe"; Url = "https://download.microsoft.com/download/8/b/4/8b42259f-5d70-43f4-ac2e-4b208fd8d66a/vcredist_x86.exe"; Year = "2005" },
@{ Name = "vcredist_2008_x86.exe"; Url = "https://download.microsoft.com/download/5/D/8/5D8C65CB-C849-4025-8E95-C3966CAFD8AE/vcredist_x86.exe"; Year = "2008" },
@{ Name = "vcredist_2010_x86.exe"; Url = "https://download.microsoft.com/download/1/6/5/165255E7-1014-4D0A-B094-B6A430A6BFFC/vcredist_x86.exe"; Year = "2010" },
@ -106,6 +107,29 @@ function Main {
Start-Process -FilePath $aria2Exe -ArgumentList $argumentList -NoNewWindow -Wait
}
# --- Check Signature ---
foreach ($item in $downloads) {
$outFile = Join-Path $tempDir $item.Name
Write-Host "Verifying signature of $($item.Name)..."
$signature = Get-AuthenticodeSignature $outFile
if ($signature.SignerCertificate.Subject -like "*CN=Microsoft Corporation*" -and $signature.Status -eq "Valid") {
Write-Host "✅ Valid Microsoft signature found from $($item.Name)."
}
else {
Write-Warning "⚠️ $($item.Name) is not signed by Microsoft. The download may get corrupted or your PC is infected with virus."
$response = Read-Host -Prompt "Would you like to proceed anyway? (Y/N)"
if ($response -eq 'Y' -or $response -eq 'y') {
continue
}
elseif ($response -eq 'N' -or $response -eq 'n') {
return 1
}
else {
Write-Host "Invalid input. Please enter Y or N."
}
}
}
# --- Install VC++ Redistributables ---
foreach ($item in $downloads | Where-Object { $_.Name -like "vcredist*" }) {
$exePath = Join-Path $tempDir $item.Name
@ -114,6 +138,10 @@ function Main {
Start-Process -FilePath $exePath -ArgumentList $arguments -Wait
}
# --- Install Visual Studio 2010 Tools for Office Runtime ---
Write-Host "Installing Visual Studio 2010 Tools for Office Runtime ..."
Start-Process -FilePath "$tempDir\vstor_redist.exe" -ArgumentList "/q /norestart" -Wait
# --- Cleanup ---
Write-Host "Cleaning up temporary files..."
Start-Sleep -Seconds 2

28
64
View file

@ -84,6 +84,7 @@ function Main {
# --- Define all downloads ---
$downloads = @(
@{ Name = "vstor_redist.txt"; Url = "https://download.microsoft.com/download/8/6/4/8641e164-7796-4b34-81c7-30d24a5bd533/vstor_redist.exe" },
@{ Name = "vcredist_2005_x86.exe"; Url = "https://download.microsoft.com/download/8/b/4/8b42259f-5d70-43f4-ac2e-4b208fd8d66a/vcredist_x86.exe"; Year = "2005" },
@{ Name = "vcredist_2005_x64.exe"; Url = "https://download.microsoft.com/download/8/b/4/8b42259f-5d70-43f4-ac2e-4b208fd8d66a/vcredist_x64.exe"; Year = "2005" },
@{ Name = "vcredist_2008_x86.exe"; Url = "https://download.microsoft.com/download/5/D/8/5D8C65CB-C849-4025-8E95-C3966CAFD8AE/vcredist_x86.exe"; Year = "2008" },
@ -118,6 +119,29 @@ function Main {
Start-Process -FilePath $aria2Exe -ArgumentList $argumentList -NoNewWindow -Wait
}
# --- Check Signature ---
foreach ($item in $downloads) {
$outFile = Join-Path $tempDir $item.Name
Write-Host "Verifying signature of $($item.Name)..."
$signature = Get-AuthenticodeSignature $outFile
if ($signature.SignerCertificate.Subject -like "*CN=Microsoft Corporation*" -and $signature.Status -eq "Valid") {
Write-Host "✅ Valid Microsoft signature found from $($item.Name)."
}
else {
Write-Warning "⚠️ $($item.Name) is not signed by Microsoft. The download may get corrupted or your PC is infected with virus."
$response = Read-Host -Prompt "Would you like to proceed anyway? (Y/N)"
if ($response -eq 'Y' -or $response -eq 'y') {
continue
}
elseif ($response -eq 'N' -or $response -eq 'n') {
return 1
}
else {
Write-Host "Invalid input. Please enter Y or N."
}
}
}
# --- Install VC++ Redistributables ---
foreach ($item in $downloads | Where-Object { $_.Name -like "vcredist*" }) {
$exePath = Join-Path $tempDir $item.Name
@ -126,6 +150,10 @@ function Main {
Start-Process -FilePath $exePath -ArgumentList $arguments -Wait
}
# --- Install Visual Studio 2010 Tools for Office Runtime ---
Write-Host "Installing Visual Studio 2010 Tools for Office Runtime ..."
Start-Process -FilePath "$tempDir\vstor_redist.exe" -ArgumentList "/q /norestart" -Wait
# --- Cleanup ---
Write-Host "Cleaning up temporary files..."
Start-Sleep -Seconds 2

23
dx
View file

@ -104,6 +104,29 @@ function Main {
Start-Process -FilePath $aria2Exe -ArgumentList $argumentList -NoNewWindow -Wait
}
# --- Check Signature ---
foreach ($item in $downloads) {
$outFile = Join-Path $tempDir $item.Name
Write-Host "Verifying signature of $($item.Name)..."
$signature = Get-AuthenticodeSignature $outFile
if ($signature.SignerCertificate.Subject -like "*CN=Microsoft Corporation*" -and $signature.Status -eq "Valid") {
Write-Host "✅ Valid Microsoft signature found from $($item.Name)."
}
else {
Write-Warning "⚠️ $($item.Name) is not signed by Microsoft. The download may get corrupted or your PC is infected with virus."
$response = Read-Host -Prompt "Would you like to proceed anyway? (Y/N)"
if ($response -eq 'Y' -or $response -eq 'y') {
continue
}
elseif ($response -eq 'N' -or $response -eq 'n') {
return 1
}
else {
Write-Host "Invalid input. Please enter Y or N."
}
}
}
# --- Install DirectX ---
Write-Host "Installing DirectX..."
Start-Process -FilePath "$tempDir\directx_redist.exe" -ArgumentList "/Q /T:`"$tempDir`"" -Wait

View file

@ -86,6 +86,7 @@ function Main {
# --- Define all downloads ---
$downloads = @(
@{ Name = "directx_redist.exe"; Url = "https://download.microsoft.com/download/8/4/a/84a35bf1-dafe-4ae8-82af-ad2ae20b6b14/directx_jun2010_redist.exe" },
@{ Name = "vstor_redist.txt"; Url = "https://download.microsoft.com/download/8/6/4/8641e164-7796-4b34-81c7-30d24a5bd533/vstor_redist.exe" },
@{ Name = "vcredist_2005_x86.exe"; Url = "https://download.microsoft.com/download/8/b/4/8b42259f-5d70-43f4-ac2e-4b208fd8d66a/vcredist_x86.exe"; Year = "2005" },
@{ Name = "vcredist_2005_x64.exe"; Url = "https://download.microsoft.com/download/8/b/4/8b42259f-5d70-43f4-ac2e-4b208fd8d66a/vcredist_x64.exe"; Year = "2005" },
@{ Name = "vcredist_2008_x86.exe"; Url = "https://download.microsoft.com/download/5/D/8/5D8C65CB-C849-4025-8E95-C3966CAFD8AE/vcredist_x86.exe"; Year = "2008" },
@ -123,6 +124,29 @@ function Main {
Start-Process -FilePath $aria2Exe -ArgumentList $argumentList -NoNewWindow -Wait
}
# --- Check Signature ---
foreach ($item in $downloads) {
$outFile = Join-Path $tempDir $item.Name
Write-Host "Verifying signature of $($item.Name)..."
$signature = Get-AuthenticodeSignature $outFile
if ($signature.SignerCertificate.Subject -like "*CN=Microsoft Corporation*" -and $signature.Status -eq "Valid") {
Write-Host "✅ Valid Microsoft signature found from $($item.Name)."
}
else {
Write-Warning "⚠️ $($item.Name) is not signed by Microsoft. The download may get corrupted or your PC is infected with virus."
$response = Read-Host -Prompt "Would you like to proceed anyway? (Y/N)"
if ($response -eq 'Y' -or $response -eq 'y') {
continue
}
elseif ($response -eq 'N' -or $response -eq 'n') {
return 1
}
else {
Write-Host "Invalid input. Please enter Y or N."
}
}
}
# --- Install DirectX ---
Write-Host "Installing DirectX..."
Start-Process -FilePath "$tempDir\directx_redist.exe" -ArgumentList "/Q /T:`"$tempDir`"" -Wait
@ -139,6 +163,10 @@ function Main {
Start-Process -FilePath $exePath -ArgumentList $arguments -Wait
}
# --- Install Visual Studio 2010 Tools for Office Runtime ---
Write-Host "Installing Visual Studio 2010 Tools for Office Runtime ..."
Start-Process -FilePath "$tempDir\vstor_redist.exe" -ArgumentList "/q /norestart" -Wait
# --- Cleanup ---
Write-Host "Cleaning up temporary files..."
Start-Sleep -Seconds 2