How to make selected screen resolution persist across sessions?

0

In AppStream 2.0, after selecting an app and logging in to the desktop, I see that my app is being displayed in the wrong screen resolution. So I close my app, click on "Preferences" and set the screen resolution to 1920x1080, and restart my app. If I log out, though, and later log back in, the screen resolution has returned to what it originally was, not what I last set it to.

I'm trying to figure out how to make my screen resolution setting persist across sessions. I've tried setting "Enable application settings persistence" (and the Settings Group) in my stack, but that doesn't end up working. I've tried adding a call to PowerShell Set-DisplayResolution in the C:\AppStream\SessionScripts\Config.JSON file. But PowerShell errors out saying that 1920x1080 is not a resolution supported by the display (despite the fact that that resolution can be manually set in Preferences).

Does anyone know how I can accomplish saving the screen resolution I want across sessions? Thanks very much.

asked 8 months ago139 views
2 Answers
0
Accepted Answer

The issue you're experiencing with the screen resolution not persisting across sessions in AppStream 2.0 is a common one. Unfortunately, there's no out-of-the-box solution to make the screen resolution setting persist, but there are a few workarounds you can try:

  1. Use a PowerShell Script:

    • Instead of relying on the built-in "Enable application settings persistence" feature, you can create a custom PowerShell script to set the screen resolution.

    • Create a PowerShell script (e.g., set-resolution.ps1) with the following content:

      $width = 1920
      $height = 1080
      $settings = Get-DisplaySettings
      $settings.Width = $width
      $settings.Height = $height
      Set-DisplaySettings -InputObject $settings
    • Upload this script to an S3 bucket and reference it in the "User Session Scripts" section of your AppStream 2.0 Stack configuration.

    • Make sure the script is set to run on the "Session Start" event.

  2. Leverage the Registry:

    • Another approach is to use the registry to set the screen resolution. This can be more reliable than the PowerShell script method.

    • Create a registry file (e.g., set-resolution.reg) with the following content:

      Windows Registry Editor Version 5.00
      
      [HKEY_CURRENT_USER\Control Panel\Desktop]
      "LogPixels"=dword:00000060
      "ScreenSizeX"=dword:00000780
      "ScreenSizeY"=dword:000003c0
      
    • The values for "ScreenSizeX" and "ScreenSizeY" correspond to 1920 and 1080, respectively.

    • Upload this registry file to an S3 bucket and reference it in the "User Session Scripts" section of your AppStream 2.0 Stack configuration.

    • Make sure the registry file is set to run on the "Session Start" event.

  3. Use a Batch File:

    • As an alternative to PowerShell, you can create a batch file (e.g., set-resolution.bat) with the following content:

      reg add "HKEY_CURRENT_USER\Control Panel\Desktop" /v ScreenSizeX /t REG_DWORD /d 1920 /f
      reg add "HKEY_CURRENT_USER\Control Panel\Desktop" /v ScreenSizeY /t REG_DWORD /d 1080 /f
      RUNDLL32.EXE USER32.DLL,UpdatePerUserSystemParameters
    • Upload this batch file to an S3 bucket and reference it in the "User Session Scripts" section of your AppStream 2.0 Stack configuration.

    • Make sure the batch file is set to run on the "Session Start" event.

Whichever method you choose, the key is to set the screen resolution programmatically during the session start, rather than relying on the user to manually change the settings. This will ensure that the resolution is set consistently across all sessions.

Remember to test the scripts thoroughly and make sure they work as expected in your AppStream 2.0 environment before deploying them to production.

answered 8 months ago
profile picture
EXPERT
reviewed 6 months ago
0

Thank you, Roy. I have a lot to learn!

answered 8 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions