Overview
The primary-VDD.ps1 script provides a simple command to set the Virtual Display Driver as the primary (main) display in Windows. This is useful when you want to use the virtual display as your main screen.
Features
- One-command operation: Sets VDD as primary display with a single command
- Automatic elevation: Self-elevates to Administrator privileges if needed
- Dependency management: Automatically installs required PowerShell modules
- Simple and fast: Minimal script focused on a single task
Requirements
This script requires Administrator privileges and will automatically request elevation through UAC if not already running as Administrator.
- Virtual Display Driver must be installed and enabled
- PowerShell 5.1 or later
- Internet connection (for first run to install dependencies)
- Required PowerShell modules (automatically installed):
DisplayConfig v1.1.1
MonitorConfig v1.0.3
Parameters
This script takes no parameters. It automatically finds the Virtual Display Driver and sets it as primary.
Usage Examples
Set VDD as Primary Display
Run from Command Prompt
powershell.exe -ExecutionPolicy Bypass -File .\primary-VDD.ps1
Run from Batch File
Create set-vdd-primary.bat:
@echo off
echo Setting Virtual Display Driver as primary...
powershell.exe -ExecutionPolicy Bypass -File "%~dp0primary-VDD.ps1"
echo Done!
pause
How It Works
1. Self-Elevation
Checks for Administrator privileges and elevates if needed:
if (-Not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] 'Administrator')) {
# Relaunch with UAC elevation
Start-Process -FilePath PowerShell.exe -Verb Runas -ArgumentList $CommandLine
Exit
}
2. Dependency Installation
Sources set-dependencies.ps1 to ensure required modules are installed:
. "$PSScriptRoot\set-dependencies.ps1"
This automatically installs and imports:
- DisplayConfig - For display management
- MonitorConfig - For monitor configuration
3. Display Identification
Finds the Virtual Display Driver by its display name:
$disp = Get-DisplayInfo | Where-Object { $_.DisplayName -eq "VDD by MTT" }
4. Set as Primary
Uses the DisplayConfig module to set the display as primary:
Set-DisplayPrimary -DisplayId $disp.DisplayId
Script Source
Here’s the complete script:
# Self-elevate the script if required
if (-Not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] 'Administrator')) {
if ([int](Get-CimInstance -Class Win32_OperatingSystem | Select-Object -ExpandProperty BuildNumber) -ge 6000) {
$CommandLine = "-File `"" + $MyInvocation.MyCommand.Path + "`" " + $MyInvocation.UnboundArguments
Start-Process -FilePath PowerShell.exe -Verb Runas -ArgumentList $CommandLine
Exit
}
}
# Install dependencies if required
. "$PSScriptRoot\set-dependencies.ps1"
$disp = Get-DisplayInfo | Where-Object { $_.DisplayName -eq "VDD by MTT" }
Set-DisplayPrimary -DisplayId $disp.DisplayId
Understanding Primary Display
What is a Primary Display?
The primary (or main) display in Windows is:
- Where the taskbar appears by default
- Where new windows open by default
- Where the Windows login screen appears
- The display labeled as “1” in Windows Display Settings
- The display positioned at coordinates (0, 0)
Why Set VDD as Primary?
Common use cases:
- Remote desktop scenarios: Set VDD as primary to ensure remote sessions use the virtual display
- Headless systems: When running without physical monitors, make VDD the primary display
- Application capture: Some applications only render to the primary display
- Streaming/recording: Capture software may default to primary display
- Multi-monitor setup: Organize your workspace with VDD as the main screen
Effects of Changing Primary Display
What changes:
- Taskbar moves to the new primary display
- Desktop icons may rearrange
- Some applications will move to the new primary display
- Login screen will appear on the new primary display
- Display coordinates are recalculated (primary is always at 0,0)
What doesn’t change:
- Other displays remain active
- Application windows on other displays stay in place (usually)
- Display arrangement in Settings
Troubleshooting
Display Not Found Error
Cause: Virtual Display Driver is not installed or enabled.
Solution:
# Check driver status
.\virtual-driver-manager.ps1 -Action status
# Enable if disabled
.\virtual-driver-manager.ps1 -Action enable
# List all displays to verify
Get-DisplayInfo | Format-Table DisplayName, DisplayId
Set-DisplayPrimary Command Not Found
Cause: DisplayConfig module is not installed or imported.
Solution:
# Manually install the module
Install-Module -Name DisplayConfig -RequiredVersion 1.1.1 -Scope CurrentUser -Force
# Import the module
Import-Module DisplayConfig
# Verify cmdlet is available
Get-Command Set-DisplayPrimary
Primary Display Doesn’t Change
Possible causes:
- Multiple displays with same name
- Display is disabled
- Windows Display Settings are locked
Solutions:
# Verify display is enabled
Get-PnpDevice | Where-Object { $_.FriendlyName -like "*Virtual Display*" }
# Check display status
$disp = Get-DisplayInfo | Where-Object { $_.DisplayName -eq "VDD by MTT" }
$disp | Format-List
# Try disabling and re-enabling
.\toggle-VDD.ps1
Start-Sleep -Seconds 2
.\toggle-VDD.ps1
Start-Sleep -Seconds 1
.\primary-VDD.ps1
Script Requires set-dependencies.ps1
Ensure both files are in the same directory:
Community Scripts/
├── primary-VDD.ps1
└── set-dependencies.ps1
If missing, download the complete Community Scripts package from the repository.
UAC Prompt Every Time
This is expected - the script needs Administrator privileges to change display settings.
Options:
- Accept the UAC prompt (recommended)
- Create a scheduled task with elevated privileges
- Use Task Scheduler to run at startup/logon
Automation Examples
Set VDD as Primary at Startup
Create a scheduled task:
$action = New-ScheduledTaskAction -Execute "powershell.exe" `
-Argument "-ExecutionPolicy Bypass -WindowStyle Hidden -File C:\Scripts\primary-VDD.ps1"
$trigger = New-ScheduledTaskTrigger -AtStartup
$principal = New-ScheduledTaskPrincipal -UserId "SYSTEM" -RunLevel Highest
$settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries
Register-ScheduledTask -TaskName "Set VDD Primary at Startup" `
-Action $action `
-Trigger $trigger `
-Principal $principal `
-Settings $settings
Keyboard Shortcut
-
Create a batch file:
@echo off
powershell.exe -ExecutionPolicy Bypass -File "C:\Scripts\primary-VDD.ps1"
-
Create a shortcut to the batch file
-
Right-click shortcut → Properties
-
Set “Shortcut key” (e.g., Ctrl+Alt+P)
-
Set “Run” to “Minimized”
-
Click “Advanced” → Check “Run as administrator”
Reset to Physical Display
If you have a physical display and want to switch back:
# List all displays
Get-DisplayInfo | Format-Table DisplayName, DisplayId
# Set a different display as primary (replace DisplayId)
$physicalDisplay = Get-DisplayInfo | Where-Object { $_.DisplayName -ne "VDD by MTT" } | Select-Object -First 1
Set-DisplayPrimary -DisplayId $physicalDisplay.DisplayId
Create reset-primary.ps1:
# Self-elevate if needed
if (-Not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] 'Administrator')) {
if ([int](Get-CimInstance -Class Win32_OperatingSystem | Select-Object -ExpandProperty BuildNumber) -ge 6000) {
$CommandLine = "-File `"" + $MyInvocation.MyCommand.Path + "`" " + $MyInvocation.UnboundArguments
Start-Process -FilePath PowerShell.exe -Verb Runas -ArgumentList $CommandLine
Exit
}
}
# Install dependencies
. "$PSScriptRoot\set-dependencies.ps1"
# Get first non-VDD display
$physicalDisplay = Get-DisplayInfo | Where-Object { $_.DisplayName -ne "VDD by MTT" } | Select-Object -First 1
if ($physicalDisplay) {
Write-Host "Setting $($physicalDisplay.DisplayName) as primary..."
Set-DisplayPrimary -DisplayId $physicalDisplay.DisplayId
} else {
Write-Warning "No other displays found!"
}
Multi-Display Configuration Script
Create a complete display setup script:
# setup-displays.ps1
param(
[switch]$VDDPrimary,
[int]$Resolution_X = 1920,
[int]$Resolution_Y = 1080,
[switch]$EnableHDR
)
# Enable VDD
Write-Host "Enabling Virtual Display Driver..."
& "$PSScriptRoot\toggle-VDD.ps1"
Start-Sleep -Seconds 2
# Set resolution
Write-Host "Setting resolution to $Resolution_X x $Resolution_Y..."
& "$PSScriptRoot\changeres-VDD.ps1" $Resolution_X $Resolution_Y
Start-Sleep -Seconds 1
# Enable HDR if requested
if ($EnableHDR) {
Write-Host "Enabling HDR..."
# Check if HDR is already enabled
$disp = Get-DisplayInfo | Where-Object { $_.DisplayName -eq "VDD by MTT" }
$bpcc = Get-DisplayColorInfo -DisplayId $disp.DisplayId | Select-Object -ExpandProperty BitsPerColorChannel
if ($bpcc -le 8) {
& "$PSScriptRoot\HDRswitch-VDD.ps1"
}
Start-Sleep -Seconds 1
}
# Set as primary if requested
if ($VDDPrimary) {
Write-Host "Setting VDD as primary display..."
& "$PSScriptRoot\primary-VDD.ps1"
}
Write-Host "Display configuration complete!"
Usage:
# Setup VDD as primary with 4K and HDR
.\setup-displays.ps1 -VDDPrimary -Resolution_X 3840 -Resolution_Y 2160 -EnableHDR
# Setup VDD with 1440p (not primary)
.\setup-displays.ps1 -Resolution_X 2560 -Resolution_Y 1440
Checking Current Primary Display
To see which display is currently primary:
# Get all displays
Get-DisplayInfo | Format-Table DisplayName, DisplayId, IsPrimary
# Or filter for primary only
Get-DisplayInfo | Where-Object { $_.IsPrimary -eq $true } | Format-List
See Also