The silent install script is really silent

This commit is contained in:
François Brunhes aka Fanfan committed 2025-09-27 23:32:50 +02:00
1 parent 7233822630
commit 830de3f2aa
1 file changed
+47 -50
+47 -50
View File
@@ -1,3 +1,4 @@
# Run this script in a powershell with administrator rights (run as administrator)
[CmdletBinding()]
param(
# SHA256 hash of the DevCon binary to install
@@ -7,64 +8,60 @@ param(
[Parameter(Mandatory=$true)]
[string]$DevconHash,
# Latest stable version of VDD
# Latest stable version of VDD driver only
[Parameter(Mandatory=$false)]
[string]$DriverVersion = "latest"
)
[string]$DriverURL = "https://github.com/VirtualDrivers/Virtual-Display-Driver/releases/download/25.7.23/VirtualDisplayDriver-x86.Driver.Only.zip"
);
# Create temp directory
$tempDir = Join-Path $env:TEMP "VDDInstall"
New-Item -ItemType Directory -Path $tempDir -Force | Out-Null
$tempDir = Join-Path $env:TEMP "VDDInstall";
New-Item -ItemType Directory -Path $tempDir -Force | Out-Null;
# Download and run DevCon Installer
Write-Host "Installing DevCon..." -ForegroundColor Cyan
$devconPath = Join-Path $tempDir "Devcon.Installer.exe"
Invoke-WebRequest -Uri "https://github.com/Drawbackz/DevCon-Installer/releases/download/1.4-rc/Devcon.Installer.exe" -OutFile $devconPath
Start-Process -FilePath $devconPath -ArgumentList "install -hash $DevconHash -update -dir `"$tempDir`"" -Wait -NoNewWindow
Write-Host "Installing DevCon..." -ForegroundColor Cyan;
$devconPath = Join-Path $tempDir "Devcon.Installer.exe";
Invoke-WebRequest -Uri "https://github.com/Drawbackz/DevCon-Installer/releases/download/1.4-rc/Devcon.Installer.exe" -OutFile $devconPath;
Start-Process -FilePath $devconPath -ArgumentList "install -hash $DevconHash -update -dir `"$tempDir`"" -Wait -NoNewWindow;
# Define path to devcon executable
$devconExe = Join-Path $tempDir "devcon.exe"
$devconExe = Join-Path $tempDir "devcon.exe";
# Handle driver download
if ($DriverVersion -eq "latest") {
Write-Host "Determining latest driver version..." -ForegroundColor Cyan
$apiUrl = "https://api.github.com/repos/VirtualDrivers/Virtual-Display-Driver/releases/latest"
$headers = @{
"Accept" = "application/vnd.github.v3+json"
"User-Agent" = "PowerShell-VDDInstaller"
}
try {
$releaseInfo = Invoke-RestMethod -Uri $apiUrl -Headers $headers
$latestVersion = $releaseInfo.tag_name
# Look for the x64 zip asset
$asset = $releaseInfo.assets | Where-Object { $_.name -match "x64\.zip$" } | Select-Object -First 1
if ($asset) {
$downloadUrl = $asset.browser_download_url
Write-Host "Found latest version: $latestVersion" -ForegroundColor Cyan
} else {
throw "Could not find x64 driver package in latest release"
}
} catch {
Write-Host "Error fetching latest release information: $_" -ForegroundColor Red
exit 1
}
# Check if VDD is installed. Or else, install it
$check = & $devconExe find "Root\MttVDD";
if ($check -match "1 matching device\(s\) found") {
Write-Host "Virtual Display Driver already present. No installation." -ForegroundColor Green;
} else {
# Use specified version
$downloadUrl = "https://github.com/VirtualDrivers/Virtual-Display-Driver/releases/download/$DriverVersion/Signed-Driver-v$DriverVersion-x64.zip"
# Download and unzip VDD
Write-Host "Downloading VDD..." -ForegroundColor Cyan;
$driverZipPath = Join-Path $tempDir 'driver.zip';
Invoke-WebRequest -Uri $DriverURL -OutFile $driverZipPath;
Expand-Archive -Path $driverZipPath -DestinationPath $tempDir -Force;
# Extract the signPath certificates
$catFile = Join-Path $tempDir 'VirtualDisplayDriver\mttvdd.cat';
$signature = Get-AuthenticodeSignature -FilePath $catFile;
$catBytes = [System.IO.File]::ReadAllBytes($catFile);
$certificates = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2Collection;
$certificates.Import($catBytes);
# Create the temp directory for certificates
$certsFolder = Join-Path $tempDir "ExportedCerts";
New-Item -ItemType Directory -Path $certsFolder;
# Write and store the driver certificates on local machine
Write-Host "Installing driver certificates on local machine." -ForegroundColor Cyan;
foreach ($cert in $certificates) {
$certFilePath = Join-Path -Path $certsFolder -ChildPath "$($cert.Thumbprint).cer";
$cert.Export([System.Security.Cryptography.X509Certificates.X509ContentType]::Cert) | Set-Content -Path $certFilePath -Encoding Byte;
Import-Certificate -FilePath $certFilePath -CertStoreLocation "Cert:\LocalMachine\TrustedPublisher";
}
# Install VDD
Push-Location $tempDir;
& $devconExe install .\VirtualDisplayDriver\MttVDD.inf "Root\MttVDD";
Pop-Location;
Write-Host "Driver installation completed." -ForegroundColor Green;
}
Remove-Item -Path $tempDir -Recurse -Force -ErrorAction SilentlyContinue;
# Download and extract driver package
Write-Host "Downloading driver from: $downloadUrl" -ForegroundColor Cyan
$driverZipPath = Join-Path $tempDir "driver.zip"
Invoke-WebRequest -Uri $downloadUrl -OutFile $driverZipPath
Expand-Archive -Path $driverZipPath -DestinationPath $tempDir -Force
# Install the driver
Write-Host "Installing virtual display driver..." -ForegroundColor Cyan
Push-Location $tempDir
& $devconExe install .\MttVDD.inf "Root\MttVDD"
Pop-Location
Write-Host "Driver installation completed." -ForegroundColor Green