# Switches the display scale between 100% and 200% for the current user. # With no argument it toggles; -Scale 100 or -Scale 200 forces a value. # The scale is stored in the registry (LogPixels), so the change takes effect only after # a restart. Use -Restart to reboot right away. param( [ValidateSet(0, 100, 200)] [int]$Scale = 0, [switch]$Restart ) $ErrorActionPreference = 'Stop' $desktopKey = 'HKCU:\Control Panel\Desktop' $metricsKey = 'HKCU:\Control Panel\Desktop\WindowMetrics' $logPixels = (Get-ItemProperty -Path $desktopKey -Name LogPixels -ErrorAction SilentlyContinue).LogPixels if (-not $logPixels) { $logPixels = 96 } $current = [int][math]::Round($logPixels * 100 / 96) $target = if ($Scale -ne 0) { $Scale } elseif ($current -eq 100) { 200 } else { 100 } $dpi = [int]($target * 96 / 100) Write-Host "Scale: $current% -> $target%" # Win8DpiScaling=1 makes Windows use LogPixels instead of the per-monitor recommendation. Set-ItemProperty -Path $desktopKey -Name LogPixels -Type DWord -Value $dpi Set-ItemProperty -Path $desktopKey -Name Win8DpiScaling -Type DWord -Value 1 Set-ItemProperty -Path $metricsKey -Name AppliedDPI -Type DWord -Value $dpi Write-Host 'Restart Windows for the new scale to take effect.' if ($Restart) { Write-Host 'Restarting in 5 seconds...' shutdown.exe /r /t 5 }