1+ # Run this script in a powershell with administrator rights (run as administrator)
12[CmdletBinding ()]
23param (
34 # SHA256 hash of the DevCon binary to install
78 [Parameter (Mandatory = $true )]
89 [string ]$DevconHash ,
910
10- # Latest stable version of VDD
11+ # Latest stable version of VDD driver only
1112 [Parameter (Mandatory = $false )]
12- [string ]$DriverVersion = " latest "
13- )
13+ [string ]$DriverURL = " https://github.com/VirtualDrivers/Virtual-Display-Driver/releases/download/25.7.23/VirtualDisplayDriver-x86.Driver.Only.zip "
14+ );
1415
1516# Create temp directory
16- $tempDir = Join-Path $env: TEMP " VDDInstall"
17- New-Item - ItemType Directory - Path $tempDir - Force | Out-Null
17+ $tempDir = Join-Path $env: TEMP " VDDInstall" ;
18+ New-Item - ItemType Directory - Path $tempDir - Force | Out-Null ;
1819
1920# Download and run DevCon Installer
20- Write-Host " Installing DevCon..." - ForegroundColor Cyan
21- $devconPath = Join-Path $tempDir " Devcon.Installer.exe"
22- Invoke-WebRequest - Uri " https://github.com/Drawbackz/DevCon-Installer/releases/download/1.4-rc/Devcon.Installer.exe" - OutFile $devconPath
23- Start-Process - FilePath $devconPath - ArgumentList " install -hash $DevconHash -update -dir `" $tempDir `" " - Wait - NoNewWindow
21+ Write-Host " Installing DevCon..." - ForegroundColor Cyan;
22+ $devconPath = Join-Path $tempDir " Devcon.Installer.exe" ;
23+ Invoke-WebRequest - Uri " https://github.com/Drawbackz/DevCon-Installer/releases/download/1.4-rc/Devcon.Installer.exe" - OutFile $devconPath ;
24+ Start-Process - FilePath $devconPath - ArgumentList " install -hash $DevconHash -update -dir `" $tempDir `" " - Wait - NoNewWindow;
2425
2526# Define path to devcon executable
26- $devconExe = Join-Path $tempDir " devcon.exe"
27+ $devconExe = Join-Path $tempDir " devcon.exe" ;
2728
28- # Handle driver download
29- if ($DriverVersion -eq " latest" ) {
30- Write-Host " Determining latest driver version..." - ForegroundColor Cyan
31- $apiUrl = " https://api.github.com/repos/VirtualDrivers/Virtual-Display-Driver/releases/latest"
32- $headers = @ {
33- " Accept" = " application/vnd.github.v3+json"
34- " User-Agent" = " PowerShell-VDDInstaller"
35- }
36-
37- try {
38- $releaseInfo = Invoke-RestMethod - Uri $apiUrl - Headers $headers
39- $latestVersion = $releaseInfo.tag_name
40- # Look for the x64 zip asset
41- $asset = $releaseInfo.assets | Where-Object { $_.name -match " x64\.zip$" } | Select-Object - First 1
42-
43- if ($asset ) {
44- $downloadUrl = $asset.browser_download_url
45- Write-Host " Found latest version: $latestVersion " - ForegroundColor Cyan
46- } else {
47- throw " Could not find x64 driver package in latest release"
48- }
49- } catch {
50- Write-Host " Error fetching latest release information: $_ " - ForegroundColor Red
51- exit 1
52- }
29+ # Check if VDD is installed. Or else, install it
30+ $check = & $devconExe find " Root\MttVDD" ;
31+ if ($check -match " 1 matching device\(s\) found" ) {
32+ Write-Host " Virtual Display Driver already present. No installation." - ForegroundColor Green;
5333} else {
54- # Use specified version
55- $downloadUrl = " https://github.com/VirtualDrivers/Virtual-Display-Driver/releases/download/$DriverVersion /Signed-Driver-v$DriverVersion -x64.zip"
56- }
34+ # Download and unzip VDD
35+ Write-Host " Downloading VDD..." - ForegroundColor Cyan;
36+ $driverZipPath = Join-Path $tempDir ' driver.zip' ;
37+ Invoke-WebRequest - Uri $DriverURL - OutFile $driverZipPath ;
38+ Expand-Archive - Path $driverZipPath - DestinationPath $tempDir - Force;
39+
40+ # Extract the signPath certificates
41+ $catFile = Join-Path $tempDir ' VirtualDisplayDriver\mttvdd.cat' ;
42+ $signature = Get-AuthenticodeSignature - FilePath $catFile ;
43+ $catBytes = [System.IO.File ]::ReadAllBytes($catFile );
44+ $certificates = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2Collection;
45+ $certificates.Import ($catBytes );
5746
58- # Download and extract driver package
59- Write-Host " Downloading driver from: $downloadUrl " - ForegroundColor Cyan
60- $driverZipPath = Join-Path $tempDir " driver.zip"
61- Invoke-WebRequest - Uri $downloadUrl - OutFile $driverZipPath
62- Expand-Archive - Path $driverZipPath - DestinationPath $tempDir - Force
47+ # Create the temp directory for certificates
48+ $certsFolder = Join-Path $tempDir " ExportedCerts" ;
49+ New-Item - ItemType Directory - Path $certsFolder ;
6350
64- # Install the driver
65- Write-Host " Installing virtual display driver..." - ForegroundColor Cyan
66- Push-Location $tempDir
67- & $devconExe install .\MttVDD.inf " Root\MttVDD"
68- Pop-Location
51+ # Write and store the driver certificates on local machine
52+ Write-Host " Installing driver certificates on local machine." - ForegroundColor Cyan;
53+ foreach ($cert in $certificates ) {
54+ $certFilePath = Join-Path - Path $certsFolder - ChildPath " $ ( $cert.Thumbprint ) .cer" ;
55+ $cert.Export ([System.Security.Cryptography.X509Certificates.X509ContentType ]::Cert) | Set-Content - Path $certFilePath - Encoding Byte;
56+ Import-Certificate - FilePath $certFilePath - CertStoreLocation " Cert:\LocalMachine\TrustedPublisher" ;
57+ }
58+
59+ # Install VDD
60+ Push-Location $tempDir ;
61+ & $devconExe install .\VirtualDisplayDriver\MttVDD.inf " Root\MttVDD" ;
62+ Pop-Location ;
63+
64+ Write-Host " Driver installation completed." - ForegroundColor Green;
65+ }
66+ Remove-Item - Path $tempDir - Recurse - Force - ErrorAction SilentlyContinue;
6967
70- Write-Host " Driver installation completed." - ForegroundColor Green
0 commit comments