Batch File to change DPI Scaling Factor

0

I'm trying to write a batch file that will change a users DPI settings when they first login. I've placed the file in the startup folder and it will prompt the user to logout before any changes are made to the registry. I don't want the users to be prompted if the changes are already made. This is what I have so far:

        @echo off
REG QUERY "HKCU\Control Panel\Desktop\WindowMetrics" /v AppliedDPI  
IF %var% == 0x78 GOTO Leave
CD\
CLS
ECHO.
:LOOP
ECHO Would you like to logoff to change Scaling of windows?
ECHO.
ECHO   Y = Logoff
ECHO   N = CANCEL and return to Windows
ECHO.
SET Choice=
SET /P Choice=TYPE YOUR CHOICE AND PRESS ENTER: 
IF NOT '%Choice%'=='' SET Choice=%Choice:~0,1%
ECHO.
IF '%Choice%'=='y' GOTO LogoffNow
IF '%Choice%'=='n' GOTO Leave
ECHO "%Choice%" is not valid. Please try again.
ECHO.
GOTO Loop
:LogoffNow
ECHO.
REG ADD "HKCU\Control Panel\Desktop" /v DpiScalingVer /t REG_DWORD /d 0x00001018 /f
REG ADD "HKLM\Software\Microsoft\Windows NT\CurrentVersion\FontDPI" /v LogPixels /t REG_DWORD /d 0x00000144 /f
REG ADD "HKCU\Control Panel\Desktop\WindowMetrics" /v AppliedDPI /t REG_DWORD /d 0x00000144 /f
REG ADD "HKCU\Control Panel\Desktop" /v Win8DpiScaling /t REG_DWORD /d 0x00000001 /f
REG ADD "HKCU\Control Panel\Desktop" /v LogPixels /t REG_DWORD /d 0x00000078 /f
shutdown /l
:Leave
batch-file
asked on Stack Overflow Dec 7, 2017 by frizzle

1 Answer

0

Change line 2 to read:

REG QUERY "HKCU\Control Panel\Desktop\WindowMetrics" /V AppliedDPI|FIND "0x78">NUL&&GOTO Leave

Also if you were to use the CHOICE command, Choice /? for usage, you could replace your entire :LOOP section with:

:LOOP
ECHO.
CHOICE /M "Would you like to logoff to change Scaling of windows"
IF ERRORLEVEL 2 GOTO Leave
:LogoffNow
answered on Stack Overflow Dec 10, 2017 by Compo

User contributions licensed under CC BY-SA 3.0