diff --git a/Community Scripts/silent-install.ps1 b/Community Scripts/silent-install.ps1 index e010e2d..9749d4e 100644 --- a/Community Scripts/silent-install.ps1 +++ b/Community Scripts/silent-install.ps1 @@ -1,12 +1,9 @@ # Run this script in a powershell with administrator rights (run as administrator) [CmdletBinding()] param( - # SHA256 hash of the DevCon binary to install - # Possible values can be found at: - # https://github.com/Drawbackz/DevCon-Installer/blob/master/devcon_sources.json - # Look for the "sha256" field in the JSON for valid hash values - [Parameter(Mandatory=$true)] - [string]$DevconHash, + # Latest stable version of NefCon installer + [Parameter(Mandatory=$false)] + [string]$NefConURL = "https://github.com/nefarius/nefcon/releases/download/v1.14.0/nefcon_v1.14.0.zip", # Latest stable version of VDD driver only [Parameter(Mandatory=$false)] @@ -17,51 +14,43 @@ param( $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; - -# Define path to devcon executable -$devconExe = Join-Path $tempDir "devcon.exe"; - -# 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 { - # 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"; - } +# Download and unzip NefCon +Write-Host "Downloading and extracting NefCon..." -ForegroundColor Cyan; +$NefConZipPath = Join-Path $tempDir "nefcon.zip"; +Invoke-WebRequest -Uri $NefConURL -OutFile $NefConZipPath -UseBasicParsing -ErrorAction Stop; +Expand-Archive -Path $NefConZipPath -DestinationPath $tempDir -Force -ErrorAction Stop; +$NefConExe = Join-Path $tempDir "x64\nefconw.exe"; + +# Download and unzip VDD +Write-Host "Downloading and extracting 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 +Write-Host "Extracting SignPath certificates..." -ForegroundColor Cyan; +$catFile = Join-Path $tempDir 'VirtualDisplayDriver\mttvdd.cat'; +$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 -Force | Out-Null; + +# 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; +# Install VDD +Write-Host "Installing Virtual Display Driver silently..." -ForegroundColor Cyan; +Push-Location $tempDir; +& $NefConExe install .\VirtualDisplayDriver\MttVDD.inf "Root\MttVDD"; +Pop-Location; - Write-Host "Driver installation completed." -ForegroundColor Green; -} +Write-Host "Driver installation completed." -ForegroundColor Green; Remove-Item -Path $tempDir -Recurse -Force -ErrorAction SilentlyContinue; -