Change "Windows font size (DPI)" in PowerShell?
As supposed in the other answers, the setting under HKLM is not the correct place as the dpi scaling is a user defined setting. The correct registry key is HKCU:\Control Panel\Desktop
with the value LogPixels
.
More information about all DPI-related registry settings can be found in DPI-related APIs and registry settings.
I wrote a tiny PowerShell script that changes the DPI scaling depending on the current scaling and performs the user logoff, so I just have to execute the script when I put my device to a different monitor.
cd 'HKCU:\Control Panel\Desktop'$val = Get-ItemProperty -Path . -Name "LogPixels"if($val.LogPixels -ne 96){ Write-Host 'Change to 100% / 96 dpi' Set-ItemProperty -Path . -Name LogPixels -Value 96} else { Write-Host 'Change to 150% / 144 dpi' Set-ItemProperty -Path . -Name LogPixels -Value 144}logoff;exit
Apparently you can set the LogPixels
property of
HKLM:/Software/Microsoft/Windows NT/CurrentVersion/FontDPI
which is reiterated in a lot of places around the net. However, I got the impression that dpi was a user setting which makes no sense to have under HKLM.
Sorry, I misread the question. I thought you wanted to control the PowerShell windows.
As already mentioned you could set the LogPixels setting in the registry, to see what the current setting is, try this:
Get-Item -Path Registry::'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\FontDPI' | Select-Object -ExpandProperty Property
If the LogPixels key is there it will show, you can create it if it does not exist:
Set-Item -Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\FontDPI\LogPixels'
NB: You have to run this with privileges that allow you to manipulate the registry.
There is a good introduction to this over at TechNet.