Skip to main content

Overview

The virtual-driver-manager.ps1 script provides a complete solution for managing the Virtual Display Driver. It handles installation, uninstallation, enabling, disabling, toggling, and status checking of the driver with automatic DevCon version resolution and administrator privilege management.

Features

  • Full lifecycle management: Install, uninstall, enable, disable, toggle, and check status
  • Interactive menu: Prompts for action selection when run without parameters
  • Automatic elevation: Self-elevates to Administrator privileges when needed
  • Smart DevCon resolution: Automatically selects the correct DevCon version using nearest-build matching
  • JSON output support: Provides machine-readable output for automation
  • Automatic cleanup: Removes temporary files after operation completes
  • Verbose diagnostics: Detailed logging with -Verbose flag

Requirements

This script requires Administrator privileges and will automatically request elevation through UAC if not already running as Administrator.
  • Windows 10 version 1809 or later, Windows 11, or Windows Server 2019+
  • PowerShell 5.1 or later
  • Internet connection (for downloading DevCon and driver files)
  • TLS 1.2 support

Parameters

-Action

Specifies the operation to perform. If omitted, the script displays an interactive menu. Type: String
Required: No (prompts if not provided)
Valid values: install, uninstall, enable, disable, toggle, status

-DriverVersion

Specifies which version of the Virtual Display Driver to install. Only used with the install action. Type: String
Required: No
Default: latest
Example: v0.0.50

-Json

Outputs all messages in JSON format for easy parsing by other programs. Type: Switch
Required: No

-Silent

Closes the script automatically without prompting for a key press. By default, the script pauses for review. Type: Switch
Required: No

-Verbose

Prints detailed diagnostic information and prevents temporary folder deletion for inspection. Type: Switch (from [CmdletBinding()])
Required: No

Usage Examples

Interactive Mode

Run without parameters to get an interactive menu:
.\virtual-driver-manager.ps1

Install Driver (Latest Version)

Install the latest driver version and pause for review:
.\virtual-driver-manager.ps1 -Action install

Install Specific Version

Install a specific driver version:
.\virtual-driver-manager.ps1 -Action install -DriverVersion v0.0.50

Uninstall Driver (Silent)

Uninstall the driver and close automatically:
.\virtual-driver-manager.ps1 -Action uninstall -Silent

Enable/Disable Driver

Enable or disable the installed driver:
# Enable the driver
.\virtual-driver-manager.ps1 -Action enable

# Disable the driver
.\virtual-driver-manager.ps1 -Action disable

Toggle Driver State

Toggle between enabled and disabled states:
.\virtual-driver-manager.ps1 -Action toggle

Check Driver Status

Check if the driver is installed and its current state:
.\virtual-driver-manager.ps1 -Action status

Automation with JSON Output

Get status in JSON format for automated processing:
powershell.exe -ExecutionPolicy Bypass -File .\virtual-driver-manager.ps1 -Action status -Json
Example JSON output:
{"installed":true,"status":"enabled","details":{"friendlyName":"Virtual Display Driver","instanceId":"ROOT\\MTTVDD\\0000","pnpDeviceID":"ROOT\\MTTVDD\\0000"}}

Enable Driver from CMD

Run from Command Prompt or batch file:
powershell.exe -ExecutionPolicy Bypass -File .\virtual-driver-manager.ps1 -Action enable -Silent

Verbose Mode for Debugging

Run with detailed logging and preserve temporary files:
.\virtual-driver-manager.ps1 -Action install -Verbose

How It Works

DevCon Version Resolution

The script uses an intelligent nearest-build matching algorithm:
  1. Detects your Windows version and build number
  2. Downloads the DevCon sources manifest from GitHub
  3. Maps version names to build numbers
  4. Selects the DevCon version using this priority:
    • Perfect match: Exact build number match
    • Older match: Newest version older than or equal to your build (safest fallback)
    • Newer match: Oldest version newer than your build (less safe but better than failing)

Self-Elevation Process

If not running as Administrator:
  1. Script detects lack of admin privileges
  2. Relaunches itself with UAC elevation prompt
  3. Passes all original parameters to the elevated process
  4. Original process waits for elevated process to complete
  5. Returns the exit code from elevated process

Automatic Cleanup

The script uses a try/catch/finally block:
  • Creates a unique temporary directory in $env:TEMP
  • Downloads DevCon and driver files to this directory
  • Always cleans up in the finally block (unless -Verbose is used)
  • Preserves temp folder in verbose mode for debugging

Actions Detail

Install

  1. Resolves the correct DevCon version for your OS
  2. Downloads and runs the DevCon Installer utility
  3. Downloads the specified driver version from GitHub releases
  4. Extracts the driver archive
  5. Uses DevCon to install the driver using the INF file and Hardware ID Root\MttVDD

Uninstall

  1. Resolves the correct DevCon version
  2. Checks if the driver device exists
  3. Uses DevCon to remove the device by Hardware ID Root\MttVDD

Enable/Disable/Toggle

  1. Finds the device by friendly name or Hardware ID
  2. Uses PowerShell’s Enable-PnpDevice or Disable-PnpDevice cmdlets
  3. For toggle: checks current status and performs the opposite action

Status

  1. Searches for the device by friendly name or Hardware ID
  2. Returns installation status and current state (enabled/disabled)
  3. Provides device details (friendly name, instance ID, PnP device ID)
  4. Outputs in human-readable format or JSON based on -Json flag

Device Detection

The script searches for the device using:
  1. Friendly Name: IddSampleDriver Device HDR or Virtual Display Driver
  2. Hardware ID (fallback): Root\MttVDD
This dual approach ensures reliable detection across different driver versions.

Exit Codes

  • 0: Operation completed successfully
  • 1: Error occurred (see error message for details)

Troubleshooting

Script Won’t Run

If you get an execution policy error, run:
powershell.exe -ExecutionPolicy Bypass -File .\virtual-driver-manager.ps1

DevCon Not Found

The script automatically downloads DevCon. If this fails:
  • Check your internet connection
  • Verify TLS 1.2 is supported on your system
  • Run with -Verbose to see detailed download information

Installation Fails

Common issues:
  • Secure Boot: May need to be disabled for unsigned test drivers
  • Test signing: May need to enable test signing mode
  • Network issues: Check GitHub connectivity
  • Permissions: Ensure running as Administrator

Check Logs with Verbose Mode

.\virtual-driver-manager.ps1 -Action install -Verbose
This will:
  • Show detailed diagnostic messages
  • Preserve the temporary directory for inspection
  • Display the exact DevCon version selected
  • Show all download URLs and file paths

Integration Examples

Task Scheduler

Create a scheduled task to enable the driver at startup:
$action = New-ScheduledTaskAction -Execute "powershell.exe" `
    -Argument "-ExecutionPolicy Bypass -File C:\Scripts\virtual-driver-manager.ps1 -Action enable -Silent"

$trigger = New-ScheduledTaskTrigger -AtStartup

$principal = New-ScheduledTaskPrincipal -UserId "SYSTEM" -RunLevel Highest

Register-ScheduledTask -TaskName "Enable VDD" -Action $action -Trigger $trigger -Principal $principal

Batch Script

Create a batch file to toggle the driver:
@echo off
powershell.exe -ExecutionPolicy Bypass -File "%~dp0virtual-driver-manager.ps1" -Action toggle -Silent

Check Status from Another Script

$statusJson = powershell.exe -ExecutionPolicy Bypass -File .\virtual-driver-manager.ps1 -Action status -Json | ConvertFrom-Json

if ($statusJson.installed -and $statusJson.status -eq "enabled") {
    Write-Host "Driver is ready!"
}

Build docs developers (and LLMs) love