Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions Community Scripts/changeres-VDD.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ param(
[int]$xres,
[Parameter(Mandatory, Position=1)]
[Alias("Y","VerticalResolution")]
[int]$yres
[int]$yres,
[Parameter(Mandatory, Position=2)]
[Alias("id","displayIndex")]
[int]$displayId
)

# Self-elevate the script if required
Expand All @@ -21,7 +24,7 @@ if (-Not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdent
. "$PSScriptRoot\set-dependencies.ps1"

# Getting the correct display
$disp = Get-DisplayInfo | Where-Object { $_.DisplayName -eq "VDD by MTT" }
#$disp = Get-DisplayInfo | Where-Object { $_.DisplayName -eq "VDD by MTT" }

# Setting the resolution on the display
Set-DisplayResolution -DisplayId $disp.DisplayId -Width $xres -Height $yres
Set-DisplayResolution -DisplayId $displayId -Width $xres -Height $yres
5 changes: 5 additions & 0 deletions Community Scripts/set-dependencies.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ if (-not (Get-PSRepository -Name $repo.Name -ErrorAction SilentlyContinue)) {
Set-PSRepository -Name $repo.Name -InstallationPolicy Trusted `
-InformationAction Ignore -WarningAction SilentlyContinue

#import DisplayConfig
Import-Module DisplayConfig
#import MonitorConfig
Import-Module MonitorConfig

# Loop through the modules and ensure they are imported & installed
foreach ($m in $modules) {

Expand Down
100 changes: 62 additions & 38 deletions Community Scripts/silent-install.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,55 +3,79 @@
param(
# 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",
[string]$NefConURL = "https://github.com/nefarius/nefcon/releases/download/v1.17.40/nefcon_v1.17.40.zip",

# Latest stable version of VDD driver only
[Parameter(Mandatory=$false)]
[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";
$tempDir = $PSScriptRoot;
New-Item -ItemType Directory -Path $tempDir -Force | Out-Null;

# 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;
# Define path to nefcon executable
$NefConExe = Join-Path $tempDir "x64\nefconc.exe";
# Download and run DevCon Installer
if (-not (Test-Path $NefConExe))
{
$NefConZipPath = Join-Path $tempDir "nefcon.zip";
if (-not (Test-Path $NefConZipPath))
{
Write-Host "Downloading NefCon..." -ForegroundColor Cyan;
Invoke-WebRequest -Uri $NefConURL -OutFile $NefConZipPath -UseBasicParsing -ErrorAction Stop;
}
Write-Host "extracting NefCon..." -ForegroundColor Cyan;
Expand-Archive -Path $NefConZipPath -DestinationPath $tempDir -Force -ErrorAction Stop;
Write-Host "extracting NefCon Completed..." -ForegroundColor Cyan;
}

# 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);
# Check if VDD is installed. Or else, install it
$check = & $NefConExe --find-hwid ---hardware-id "Root\MttVDD";
if ($check -match "Virtual Display Driver") {
Write-Host "Virtual Display Driver already present. No installation." -ForegroundColor Green;
} else {
# Extract the signPath certificates
$catFile = Join-Path $tempDir 'VirtualDisplayDriver\mttvdd.cat';
if (-not (Test-Path $catFile)){
# Download and unzip VDD
$driverZipPath = Join-Path $tempDir 'driver.zip';
if (-not (Test-Path $driverZipPath))
{
Write-Host "Downloading VDD..." -ForegroundColor Cyan;
Invoke-WebRequest -Uri $DriverURL -OutFile $driverZipPath;
}
Expand-Archive -Path $driverZipPath -DestinationPath $tempDir -Force;
}

# Create the temp directory for certificates
$certsFolder = Join-Path $tempDir "ExportedCerts";
New-Item -ItemType Directory -Path $certsFolder -Force | Out-Null;
# Extract the SignPath certificates
Write-Host "Extracting SignPath certificates..." -ForegroundColor Cyan;
$signature = Get-AuthenticodeSignature -FilePath $catFile;
$catBytes = [System.IO.File]::ReadAllBytes($catFile);
$certificates = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2Collection;
$certificates.Import($catBytes);

# 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";
}
# Create the temp directory for certificates
$certsFolder = Join-Path $tempDir "ExportedCerts";
if (-not (Test-Path $certsFolder))
{
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
Write-Host "Installing Virtual Display Driver silently..." -ForegroundColor Cyan;
Push-Location $tempDir;
& $NefConExe install .\VirtualDisplayDriver\MttVDD.inf "Root\MttVDD";
Start-Sleep -Seconds 10;
Pop-Location;
# Install VDD
Write-Host "Installing Virtual Display Driver silently..." -ForegroundColor Cyan;
Push-Location $tempDir;
& $NefConExe install .\VirtualDisplayDriver\MttVDD.inf "Root\MttVDD";
Start-Sleep -Seconds 2;
Pop-Location;

Write-Host "Driver installation completed." -ForegroundColor Green;
Remove-Item -Path $tempDir -Recurse -Force -ErrorAction SilentlyContinue;
Write-Host "Driver installation completed." -ForegroundColor Green;
}
#Remove-Item -Path $tempDir -Recurse -Force -ErrorAction SilentlyContinue;
16 changes: 16 additions & 0 deletions Community Scripts/silent-uninstall.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Run this script in a powershell with administrator rights (run as administrator)
[CmdletBinding()]
param(

);

# Create temp directory
$tempDir = $PSScriptRoot;
New-Item -ItemType Directory -Path $tempDir -Force | Out-Null;
$NefConExe = Join-Path $tempDir "x64\nefconc.exe";
Push-Location $tempDir;
& $NefConExe remove "Root\MttVDD";
& $NefConExe --uninstall-driver --inf-path .\VirtualDisplayDriver\VirtualDisplayDriver.inf;
Write-Host "Driver installation removed." -ForegroundColor Green;
Pop-Location;

33 changes: 33 additions & 0 deletions Community Scripts/vdd-install.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
@echo off
chcp 65001

REM 以下两个命令需手动执行一次

REM 解除系统签名验证体系
REM bcdedit -set loadoptions DISABLE_INTEGRITY_CHECKS

REM 设置系统进入测试模式
REM bcdedit -set TESTSIGNING ON

REM 将我们的配置目录写入注册表
rem install
set "DRIVER_DIR=%~dp0VirtualDisplayDriver"
echo driver directory:%DRIVER_DIR%
rem Get root directory,current in the scripts directory.
for %%I in ("%~dp0\..\..") do set "ROOT_DIR=%%~fI"
set "CONFIG_DIR=%ROOT_DIR%\config"
set "VDD_CONFIG=%CONFIG_DIR%\vdd_settings.xml"
echo driver config path: %VDD_CONFIG%
REM 总是从原始目录中拷贝配置到配置目录,不管是用于恢复还是备份,都是不错的选择
copy "%DRIVER_DIR%\vdd_settings.xml" "%VDD_CONFIG%"
REM 因为默认读的是注册表配置的目录,我们需要将注册表的目录配置一下
reg add "HKLM\SOFTWARE\MikeTheTech\VirtualDisplayDriver" /v VDDPATH /t REG_SZ /d "%CONFIG_DIR%" /f

REM 安装具体的驱动
powershell.exe -ExecutionPolicy Bypass -File "%~dp0silent-install.ps1"

REM 初次安装后,还应设置成扩展这些显示器的显示模式
powershell -NoProfile -ExecutionPolicy Bypass -Command "& "C:\Windows\System32\DisplaySwitch.exe" /extend"

REM 安装后,先禁用显示驱动
powershell.exe -ExecutionPolicy Bypass -File "%~dp0\virtual-driver-manager.ps1" disable --silent true
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
@echo off

:: Use PowerShell for elevation check and execution
powershell -NoProfile -ExecutionPolicy Bypass -Command ^
"$elevated = ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] 'Administrator');" ^
"if (-not $elevated) {" ^
"$CommandLine = '-File \"' + $MyInvocation.MyCommand.Path + '\" ' + $MyInvocation.UnboundArguments;" ^
"Start-Process -FilePath PowerShell.exe -Verb Runas -ArgumentList $CommandLine;" ^
"Exit" ^
"} else {" ^
"Install-Module -Name DisplayConfig -Scope AllUsers -Force -AllowClobber;" ^
"Install-Module -Name MonitorConfig -Scope AllUsers -Force -AllowClobber;" ^
"if ($?) {" ^
"Write-Output 'Modules installed successfully.'" ^
"} else {" ^
"Write-Output 'An error occurred while installing the modules.'" ^
"}" ^
"}"

pause
@echo off
chcp 65001

:: Use PowerShell for elevation check and execution
powershell -NoProfile -ExecutionPolicy Bypass -Command ^
"$elevated = ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] 'Administrator');" ^
"if (-not $elevated) {" ^
"$CommandLine = '-File \"' + $MyInvocation.MyCommand.Path + '\" ' + $MyInvocation.UnboundArguments;" ^
"Start-Process -FilePath PowerShell.exe -Verb Runas -ArgumentList $CommandLine;" ^
"Exit" ^
"} else {" ^
"Install-Module -Name DisplayConfig -Scope AllUsers -Force -AllowClobber;" ^
"Install-Module -Name MonitorConfig -Scope AllUsers -Force -AllowClobber;" ^
"if ($?) {" ^
"Write-Output 'Modules installed successfully.'" ^
"} else {" ^
"Write-Output 'An error occurred while installing the modules.'" ^
"}" ^
"}"
4 changes: 4 additions & 0 deletions Community Scripts/vdd-uninstall.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@echo off
chcp 65001

powershell.exe -ExecutionPolicy Bypass -File "%~dp0\silent-uninstall.ps1"
Loading