11# Run this script in a powershell with administrator rights (run as administrator)
22[CmdletBinding ()]
33param (
4- # SHA256 hash of the DevCon binary to install
5- # Possible values can be found at:
6- # https://github.com/Drawbackz/DevCon-Installer/blob/master/devcon_sources.json
7- # Look for the "sha256" field in the JSON for valid hash values
8- [Parameter (Mandatory = $true )]
9- [string ]$DevconHash ,
4+ # Latest stable version of NefCon installer
5+ [Parameter (Mandatory = $false )]
6+ [string ]$NefConURL = " https://github.com/nefarius/nefcon/releases/download/v1.14.0/nefcon_v1.14.0.zip" ,
107
118 # Latest stable version of VDD driver only
129 [Parameter (Mandatory = $false )]
@@ -17,51 +14,43 @@ param(
1714$tempDir = Join-Path $env: TEMP " VDDInstall" ;
1815New-Item - ItemType Directory - Path $tempDir - Force | Out-Null ;
1916
20- # Download and run DevCon Installer
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;
25-
26- # Define path to devcon executable
27- $devconExe = Join-Path $tempDir " devcon.exe" ;
28-
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;
33- } else {
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 );
46-
47- # Create the temp directory for certificates
48- $certsFolder = Join-Path $tempDir " ExportedCerts" ;
49- New-Item - ItemType Directory - Path $certsFolder ;
50-
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- }
17+ # Download and unzip NefCon
18+ Write-Host " Downloading and extracting NefCon..." - ForegroundColor Cyan;
19+ $NefConZipPath = Join-Path $tempDir " nefcon.zip" ;
20+ Invoke-WebRequest - Uri $NefConURL - OutFile $NefConZipPath - UseBasicParsing - ErrorAction Stop;
21+ Expand-Archive - Path $NefConZipPath - DestinationPath $tempDir - Force - ErrorAction Stop;
22+ $NefConExe = Join-Path $tempDir " x64\nefconw.exe" ;
23+
24+ # Download and unzip VDD
25+ Write-Host " Downloading and extracting VDD..." - ForegroundColor Cyan;
26+ $driverZipPath = Join-Path $tempDir ' driver.zip' ;
27+ Invoke-WebRequest - Uri $DriverURL - OutFile $driverZipPath ;
28+ Expand-Archive - Path $driverZipPath - DestinationPath $tempDir - Force;
29+
30+ # Extract the SignPath certificates
31+ Write-Host " Extracting SignPath certificates..." - ForegroundColor Cyan;
32+ $catFile = Join-Path $tempDir ' VirtualDisplayDriver\mttvdd.cat' ;
33+ $catBytes = [System.IO.File ]::ReadAllBytes($catFile );
34+ $certificates = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2Collection;
35+ $certificates.Import ($catBytes );
36+
37+ # Create the temp directory for certificates
38+ $certsFolder = Join-Path $tempDir " ExportedCerts" ;
39+ New-Item - ItemType Directory - Path $certsFolder - Force | Out-Null ;
40+
41+ # Write and store the driver certificates on local machine
42+ Write-Host " Installing driver certificates on local machine." - ForegroundColor Cyan;
43+ foreach ($cert in $certificates ) {
44+ $certFilePath = Join-Path - Path $certsFolder - ChildPath " $ ( $cert.Thumbprint ) .cer" ;
45+ $cert.Export ([System.Security.Cryptography.X509Certificates.X509ContentType ]::Cert) | Set-Content - Path $certFilePath - Encoding Byte;
46+ Import-Certificate - FilePath $certFilePath - CertStoreLocation " Cert:\LocalMachine\TrustedPublisher" ;
47+ }
5848
59- # Install VDD
60- Push-Location $tempDir ;
61- & $devconExe install .\VirtualDisplayDriver\MttVDD.inf " Root\MttVDD" ;
62- Pop-Location ;
49+ # Install VDD
50+ Write-Host " Installing Virtual Display Driver silently..." - ForegroundColor Cyan;
51+ Push-Location $tempDir ;
52+ & $NefConExe install .\VirtualDisplayDriver\MttVDD.inf " Root\MttVDD" ;
53+ Pop-Location ;
6354
64- Write-Host " Driver installation completed." - ForegroundColor Green;
65- }
55+ Write-Host " Driver installation completed." - ForegroundColor Green;
6656Remove-Item - Path $tempDir - Recurse - Force - ErrorAction SilentlyContinue;
67-
0 commit comments