Topic: "Turn Off the Default DPI scaling" not working when switch to Admin used  (Read 174 times)

realdragonluv

  • Jr. Chef
  • **
  • Date Registered: Oct 2015
  • Posts: 21

I'm facing an issue with the DPI setting, when I don't go into Admin it properly keeps the "Turn Off the Default DPI scaling" scaling item in force.  This is under Build Core -> Additional Options 

If I switch to admin, which I have to do for the application I need to run, then everything is tiny and it appears to be ignoring the setting of "Turn Off the Default DPI scaling" 

Resolution reports as the same in both regular and admin loads but it appears to not keep the DPI setting of choice.  (If I uncheck the "Turn Off the Default DPI scaling" then both regular user and admin have the tiny unreadable icons/text as expected so I know that is most likely the setting I need but it just doesn't seem to be applied to the admin side as well)

Before you click Yes to the "admin" prompt everything is larger as it should be with that setting checked:
        - it is not until you click "Yes" that it seems to start to ignore that setting and everything becomes tiny and unreadable on a 4k 15" laptop screen
        - If you click No to the admin prompt the DPI ignore setting is kept and the desktop loads with normal readable icons

Any help would be appreciated

Long time user of the project over the years and appreciate and thank all the hard work.  I'm hoping this is an easy fix or something I'm missing do I need to change something in the PECMDAdmin.ini maybe to make it stick?

screenshots attached

realdragonluv

  • Jr. Chef
  • **
  • Date Registered: Oct 2015
  • Posts: 21
2nd screenshot as regular user

Jimehc

  • Chef
  • ***
  • Date Registered: Jan 2015
  • Posts: 134
DPI scaling is turned off via the registry - Control Panel\Desktop\Win8DpiScaling - with a value of 0

realdragonluv

  • Jr. Chef
  • **
  • Date Registered: Oct 2015
  • Posts: 21
Thank you Jimehc. 

I just looked into this and the strange thing is they are already set to 0 when I log in for both regular and admin in the following locations: HKCU location, The HKUser control Panel, the HKUser S-1-5-18 (Regular user profile) and S-1-5-21... (which appears to be the Admin profile as it is only there when logged in as admin)  The only difference is that with this admin profile instead of just being S-1-5-## like all the other profiles it is S-1-5-##- about another 33 random numbers -> S-1-5-##-#########-##########-#########-###

I'm wondering if the issue is that this profile is being generated on the fly instead of already existing maybe?

So far it looks like the registry item appears to be set correctly but then appears that it is being ignored during the admin load process  :(

I also tried to look for %WinDir%\System32\PreCreateAdminProfile.bat and could not locate it on the build?  (I was thinking to see if there was something in there I can modify on the profile creation maybe)

Any other ideas or pointers?
« Last Edit: April 28, 2021, 12:11:04 PM by realdragonluv »

Jimehc

  • Chef
  • ***
  • Date Registered: Jan 2015
  • Posts: 134
It is encoded into > \Win10XPE\Projects\Win10XPE\Features\Admin.Script
You have two options with that - 1) set the script variable to True or Set the Level to 3 and manually extract it from the Admin.script
It maybe be an experimental feature as the process is set to False by default

realdragonluv

  • Jr. Chef
  • **
  • Date Registered: Oct 2015
  • Posts: 21
Hmm I'm thinking that may be a bit above my level of comfort for the manually extract but may look into it. 

On another note while looking in the registry I did find the below differences that may be causing the issue here:

Under the same tree as the registry Desktop folder in both HKCU and HKUser one sub folder down is -> Window Metrics -> AppliedDPI The variable on the user account is always higher than on the admin account.  For Example:
On the 4k display it is 288 for the regular user  (shows up great and readable) but when you log in as admin it is 144 (Too tiny)
On a lower resolution screen it is set to 144 (Nice and readable) for the regular user but sets to 96 for the admin (Very Tiny)

Any advice on this or potential fixes I could try?

As always appreciate the help from everyone in the community

Jimehc

  • Chef
  • ***
  • Date Registered: Jan 2015
  • Posts: 134
Sorry, got nothing else for ya.. Maybe somebody else will chime in..

realdragonluv

  • Jr. Chef
  • **
  • Date Registered: Oct 2015
  • Posts: 21
Thank you for all the help so far Jimehc  :thumbsup: , I think you got me on the right path at least as the lower numbers result in smaller text.  Now I just have to figure out a way to have it apply properly to the Admin account just like it does with the regular user account.  I'm just not sure why it would interpret differently for that one variable.

From documentation:

96   100% scaling on every display
120   125% scaling on every display
144   150% scaling on every display
192   200% scaling on every display
<other>   <other> 96/100 scaling on every display

The only other real difference is that only when logged in at admin there is an extra Key under the Desktop Tree for DPIScallingVersion -> 4096 , which is not present when logged in as the regular user.

Hopeing someone will have an answer or possible fix(s) to try out.  Fingers crossed

PetePossum

  • Jr. Chef
  • **
  • Date Registered: Mar 2016
  • Posts: 51
Hi,

I am presetting the DPI Scaling to 125% in my PE Build, by using the small script below. This works for Admin User and System. Plugin is below components on my PE.

At runtime, I am using shortcuts to switch to 100%, 150% or 200%, depending on what works best on the target system. The Shortcuts call cmd files. One example is below as well. The problem with switching at runtime is that you need to logoff/login to activate the new setting. So one part of the cmd is to activate auto login for administrator to make it more convenient. It also activates a kind of "login script", to call some autoruns after login again.

I have never put this into a standard ready to use plugin, but use simple copy commands and create links at login instead.

Hope this helps!


---- DPI 150.cmd

cd /d "%~dp0"
@echo off
cls
regedit.exe /s "%~dp0150.reg" > nul
regedit.exe /s "%~dp0Loginscript.reg" > nul
shutdown -l

--- DPI150.reg
Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Control Panel\Desktop]
"LogPixels"=dword:00000090
"Win8DpiScaling"=dword:00000001

--- Logonscript.reg
Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run]
"LoginScript"="y:\\Programs\\LoginScript\\LoginScript.cmd"

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon]
"AutoAdminLogon"="1"
"ForceAutoLogon"="1"

---- Script for default DPI 125% -----
[Main]
Title=DPI125
Type=XPEPlugin
Description=DPI125
Contact=
Version=004
Level=5
Download_Level=2
Selected=True
Mandatory=False
NoWarning=False

[PROCESS]
Echo,"Prepare the Default registry..."
RegHiveLoad,Tmp_Default,%RegDefault%
ACLRegKey,Tmp_Default
Run,%ScriptFile%,EditReg_Default
RegHiveUnLoad,Tmp_Default
//Echo,"Save the Default registry in cache..."
//FileCopy,%GTarget_Sys%\Config\DEFAULT,%XPECache%
//IniWrite,%XPECache%\HiveCache.ini,Cache,Default,True

[EditReg_Default]
RegWrite,HKLM,0x4,"Tmp_Default\Control Panel\Desktop",LogPixels,120
RegWrite,HKLM,0x4,"Tmp_Default\Control Panel\Desktop",Win8DpiScaling,1

realdragonluv

  • Jr. Chef
  • **
  • Date Registered: Oct 2015
  • Posts: 21
Thank you!!!  Thank you!  You are a life saver!   :great:

That did the trick perfectly with just the inline script in the build.  I set it to 288 on the 4k laptop and that worked on login.  I cannot tell you how much I appreciate your help with this.

I do have a follow-up question, as I have never played around with "plugins" so much.  Can this do any type of logic when the OS loads or is this only updating the registry in the build process? For example:

Load the reg hive like in your script and then read TMP_Default\Control Panel\Desktop\MaxMonitorDimension

[Process]
.....
if Control Panel\Desktop\MaxMonitorDimension is 3840 Run,%ScriptFile%,EditReg_288
if Control Panel\Desktop\MaxMonitorDimension is 1920 Run,%ScriptFile%,EditReg_144
etc...

[EditReg_288]
RegWrite,HKLM,0x4,"Tmp_Default\Control Panel\Desktop",   ,288
RegWrite,HKLM,0x4,"Tmp_Default\Control Panel\Desktop",Win8DpiScaling,1

[EditReg_144]
RegWrite,HKLM,0x4,"Tmp_Default\Control Panel\Desktop",   ,144
RegWrite,HKLM,0x4,"Tmp_Default\Control Panel\Desktop",Win8DpiScaling,1
« Last Edit: April 29, 2021, 12:59:37 PM by realdragonluv »

PetePossum

  • Jr. Chef
  • **
  • Date Registered: Mar 2016
  • Posts: 51
Glad I could help.

I see 2 ways:

- At runtime -

The script could read the current resolution and set the desired scaling based on that value, I just have never put any effort in implementing such logic.

Also keep in mind, that on some machines you might not have the proper video driver installed under PE. So the real high resolutions might not be available anyway.

- At Build time -

If you want to read the resolution at build time and pre-polulate the scaling value based on the resolution, this would select the desired value based on the hardware of the machine you build on. if you talk about 4K , you would end up with very high scaling. If you run PE on the same machine, this would work OK. If you start PE on another machine (may be Laptop 1366x766) with that scaling this would look terrible I guess ;)

- Thought -

As I typically use PE on a lot of different machines, I found that 125% is a good compromise for most machines. I just change it as required by having 3 different icons on the desktop (100, 150, 200). This is manual work, but works OK for me :)






realdragonluv

  • Jr. Chef
  • **
  • Date Registered: Oct 2015
  • Posts: 21
Thank you for the info.

In the meantime I put together a PowerShell script to address the different models out there and combined that with your CMD files.  I just used PS2EXE to make it an exe and run it as needed if the default 144 I use is not correct.  (In my case I could also used a predefined Model name to set the correct DPI

My plan is to either have my auto launched Technician app check the DPI based on the current MaxMonitorDimension and if it falls in the correct range proceed and if not run the below PowerShell or just have the "autores.exe" run on boot.

Here is the PowerShell code in case anyone wants to use it in the future
-----------------------------------------------------------------------------------------------------------------------------------
See Below post for updated code
« Last Edit: April 29, 2021, 08:21:22 PM by realdragonluv »

realdragonluv

  • Jr. Chef
  • **
  • Date Registered: Oct 2015
  • Posts: 21
Here is an updated more final PowerShell Core script for anyone that may need it in the future.  Items I added/fixed:

- You can now set this to autorun as soon as admin logs in (Simply add an entry to pecmd,ini as shown below).  I put the exe on the desktop for Default User and have it autorun on login.  If DPI needs to be changed it does it right away automatically.

...
CALL NetInit
TIPS  The Configuration is Finished.,,1,#1
EXEC %Desktop%\autores.exe
EXIT
...

Changes / Fixes:
- Only logs off and logs back in if DPI change is needed
- First time it runs no Dialog box regardless if a change is needed or not.  If no change is needed nothing happens visually but generates x:\AutoResLog.txt
- If AutoRes is launched again and no change is needed then it will generate a dialog box stating the current MaxMonitorDimension and the current DPI (aka Win8DPIScaling)

I hope this helps someone in the future to automate! 

You can adjust the 'LogPixels' values to suit your needs and add additional 'If' segments to break the ranges down further.  If there are any requests I can try to help refine it.

------------- Powershell Code Below (Must use PS2EXE or similar to convert to EXE) --------------------


function Show-MessageBox {
  [CmdletBinding(PositionalBinding=$false)]
  param(
    [Parameter(Mandatory, Position=0)]
    [string] $Message,
    [Parameter(Position=1)]
    [string] $Title,
    [Parameter(Position=2)]
    [ValidateSet('OK', 'OKCancel', 'AbortRetryIgnore', 'YesNoCancel', 'YesNo', 'RetryCancel')]
    [string] $Buttons = 'OK',
    [ValidateSet('Information', 'Warning', 'Stop')]
    [string] $Icon = 'Information',
    [ValidateSet(0, 1, 2)]
    [int] $DefaultButtonIndex
  )

  Set-StrictMode -Off

  $buttonMap = @{
    'OK'               = @{ buttonList = 'OK'; defaultButtonIndex = 0 }
    'OKCancel'         = @{ buttonList = 'OK', 'Cancel'; defaultButtonIndex = 0; cancelButtonIndex = 1 }
    'AbortRetryIgnore' = @{ buttonList = 'Abort', 'Retry', 'Ignore'; defaultButtonIndex = 2; ; cancelButtonIndex = 0 };
    'YesNoCancel'      = @{ buttonList = 'Yes', 'No', 'Cancel'; defaultButtonIndex = 2; cancelButtonIndex = 2 };
    'YesNo'            = @{ buttonList = 'Yes', 'No'; defaultButtonIndex = 0; cancelButtonIndex = 1 }
    'RetryCancel'      = @{ buttonList = 'Retry', 'Cancel'; defaultButtonIndex = 0; cancelButtonIndex = 1 }
  }

  $numButtons = $buttonMap[$Buttons].buttonList.Count
  $defaultIndex = [math]::Min($numButtons - 1, ($buttonMap[$Buttons].defaultButtonIndex, $DefaultButtonIndex)[$PSBoundParameters.ContainsKey('DefaultButtonIndex')])
  $cancelIndex = $buttonMap[$Buttons].cancelButtonIndex

    Add-Type -Assembly System.Windows.Forms       
    # Show the dialog. Output the chosen button as a stringified [System.Windows.Forms.DialogResult] enum value
    [System.Windows.Forms.MessageBox]::Show($Message, $Title, $Buttons, $Icon, $defaultIndex * 256).ToString()
}

Start-Sleep 3

$key = 'HKCU:\Control Panel\Desktop'
$MonitorRes = (Get-ItemProperty -Path $key -Name MaxMonitorDimension).MaxMonitorDimension
$CurrentDPI = (Get-ItemProperty -Path $key -Name LogPixels).LogPixels

If (($MonitorRes -gt 3000) -and ($CurrentDPI -ne "288")) {
    Add-Content "x:\AutoResLog.txt" ((Get-Date -Format "MM/dd/yyyy HH:mm") + " - DPI has to be updated to 288 for Monitor width of " + $MonitorRes + " and DPI setting of " + $CurrentDPI)
    #Show-MessageBox ("DPI has to be updated to 288 for Monitor width of $MonitorRes and DPI setting of $CurrentDPI")("288 DPI change needed")("OK") ##### Remove leading # to see a dialog box with current MaxMonitorDimension and DPI
    Set-ItemProperty -Path 'HKCU:\Control Panel\Desktop' -Name 'LogPixels' -Value '288'
    Set-ItemProperty -Path 'HKCU:\Control Panel\Desktop' -Name 'Win8DpiScaling' -Value '1'
    Set-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon' -Name 'AutoAdminLogon' -Value '1'
    Set-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon' -Name 'ForceAutoLogon' -Value '1'
    "shutdown -l" | cmd
}
If ((($MonitorRes -ge 1920) -and ($MonitorRes -lt 3000)) -and ($CurrentDPI -ne "144")) {
    Add-Content "x:\AutoResLog.txt" ((Get-Date -Format "MM/dd/yyyy HH:mm") + " - DPI has to be updated to 288 for Monitor width of " + $MonitorRes + " and DPI setting of " + $CurrentDPI)
    #Show-MessageBox ("DPI has to be updated to 144 for Monitor width of $MonitorRes and DPI setting of $CurrentDPI")("288 DPI change needed")("OK") ##### Remove leading # to see a dialog box with current MaxMonitorDimension and DPI
    Set-ItemProperty -Path 'HKCU:\Control Panel\Desktop' -Name 'LogPixels' -Value '144'
    Set-ItemProperty -Path 'HKCU:\Control Panel\Desktop' -Name 'Win8DpiScaling' -Value '1'
    Set-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon' -Name 'AutoAdminLogon' -Value '1'
    Set-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon' -Name 'ForceAutoLogon' -Value '1'
    "shutdown -l" | cmd
}
If (($MonitorRes -lt 1920) -and ($CurrentDPI -ne "96")) {
    Add-Content "x:\AutoResLog.txt" ((Get-Date -Format "MM/dd/yyyy HH:mm") + " - DPI has to be updated to 96 for Monitor width of " + $MonitorRes + " and DPI setting of " + $CurrentDPI)
    #Show-MessageBox ("DPI has to be updated to 96 for Monitor width of $MonitorRes and DPI setting of $CurrentDPI")("288 DPI change needed")("OK")  ##### Remove leading # to see a dialog box with current MaxMonitorDimension and DPI
    Set-ItemProperty -Path 'HKCU:\Control Panel\Desktop' -Name 'LogPixels' -Value '96'
    Set-ItemProperty -Path 'HKCU:\Control Panel\Desktop' -Name 'Win8DpiScaling' -Value '1'
    Set-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon' -Name 'AutoAdminLogon' -Value '1'
    Set-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon' -Name 'ForceAutoLogon' -Value '1'
    "shutdown -l" | cmd
}

If (Test-Path -LiteralPath "x:\AutoResLog.txt") {
    Show-MessageBox ("DPI Setting appears to already be set to the optimal setting for Monitor width of $MonitorRes and DPI setting of $CurrentDPI")("NO DPI change needed")("OK")
}
Else {
    Add-Content "x:\AutoResLog.txt" ((Get-Date -Format "MM/dd/yyyy HH:mm") + " - DPI already optimal for Monitor width of " + $MonitorRes + " and DPI setting of " + $CurrentDPI)
}

« Last Edit: April 30, 2021, 11:33:25 AM by realdragonluv »

PetePossum

  • Jr. Chef
  • **
  • Date Registered: Mar 2016
  • Posts: 51
Thanks a lot for sharing! I will definitely take a closer look if I find time :)

 

Powered by EzPortal