Change Windows EC2 instance default screen resolution

4 minute read
Content level: Intermediate
2

How to configure the default display screen resolution of an EC2 instance running Windows Server?

Overview

You may be using EC2 instances for browser automation testing (with software such as Selenium), video processing, or cloud gaming; and require a higher or custom Windows screen resolution than the default 1024 by 768.

This article suggests how you can configure higher or custom default screen resolution on Windows EC2 instances using Amazon DCV server.

Notice

Your use of Amazon DCV is subject to DCV end user license agreement

Other options

To launch a Windows EC2 instance with GPU, refer to blog post Building a high-performance Windows workstation on AWS for graphics intensive applications

Launch Windows EC2 instance

Launch a Nitro based Windows EC2 instance with the following configuration

{
    "Version": "2012-10-17",
    "Statement": [
       {
           "Effect": "Allow",
           "Action": "s3:GetObject",
           "Resource": "arn:aws:s3:::dcv-license.region/*"
       }
    ]
}

* On Windows Server 2019 or later, DCV server version 2023.1 or later installs Indirect Display Driver (IDD) which significantly reduces overall CPU usage and enables support for higher display resolutions.

Install Amazon DCV server

Connect to your Windows instances using RDP client or Fleet Manager.

Download nice-dcv-server-x64-Release.msi and install.

Configure default resolution

To configure default screen resolution of 1920 by 1080, run the following command from administrator command prompt or powershell session.

reg.exe add HKEY_USERS\S-1-5-18\Software\GSettings\com\nicesoftware\dcv\display /v console-session-default-layout /t REG_SZ /d "[{'w':<1920>, 'h':<1080>, 'x':<0>, 'y': <0>}]" /f

Optional: Limit resolution change

When you connect to DCV session, DCV server automatically adapts display resolution to match the current size of a connected client.

To configure a minimum 1920 by 1080 resolution from default 640 by 480.

reg add HKEY_USERS\S-1-5-18\Software\GSettings\com\nicesoftware\dcv\display /v min-head-resolution /t REG_SZ /d "(1920, 1080)" /f

Optional: To block NICE DCV client from changing display resolution.

reg add HKEY_USERS\S-1-5-18\Software\GSettings\com\nicesoftware\dcv\display /v enable-client-resize /t REG_DWORD /d 0  /f

Refer to Amazon DCV Server parameter reference for details and other options.

Apply changes

Either restart Windows, or restart DCV server to apply changes

Verify resolution

SSM session manager

You can connect using SSM Session Manager.

gwmi win32_VideoController | select-object Description, VideoModeDescription
gwmi win32_DesktopMonitor | select-object DeviceID, ScreenWidth, ScreenHeight
&"C:\Program Files\NICE\DCV\Server\bin\dcv.exe" describe-session console

Output should be similar to below.

PS C:\Windows\system32> gwmi win32_VideoController | select-object Description, VideoModeDescription

Description                     VideoModeDescription
-----------                     --------------------
Microsoft Basic Display Adapter 1024 x 768 x 4294967296 colors
AWS Indirect Display Device     1920 x 1080 x 4294967296 colors


PS C:\Windows\system32> gwmi win32_DesktopMonitor | select-object DeviceID, ScreenWidth, ScreenHeight

DeviceID        ScreenWidth ScreenHeight
--------        ------------ -----------
DesktopMonitor1         1920        1080
DesktopMonitor2


PS C:\Windows\system32> &"C:\Program Files\NICE\DCV\Server\bin\dcv.exe" describe-session console
Session:
        id: console
        owner: administrator
        display layout: 1920x1080+0+0
PS C:\Windows\system32>

Connect using DCV

You can connect to EC2 Windows instance using DCV web browser client at https://<EC2-IP>:8443 (where <EC2-IP> is your EC2 instance IP address). Native clients support additional features and can be downloaded from Amazon DCV site. Do ensure that EC2 instance security group allow inbound TCP and UDP 8443 from your IP

Below screenshot is t3.medium EC2 instance running Windows Server 2022. Notice that the display connected to Microsoft Basic Display Adapter is not active, while the display connected to AWS Indirect Display Device is active and has a resolution of 1920 x 1080.

EC2 instance with 1920 by 1080 resolution

To manually change display resolution, for example to 2560 by 1440.

cd "\Program Files\NICE\DCV\Server\bin"
.\dcv set-display-layout --session console 2560x1440+0+0

Optional: Configure default resolution when launching new EC2 instance

To configure default minimum 1920 by 1080 resolution when launching a new Windows EC2 instance, you can use the below as user data.

<script>
cd \windows\temp
powershell -command "[System.Net.ServicePointManager]::SecurityProtocol = 3072; (New-Object System.Net.WebClient).DownloadFile('https://d1uj6qtbmh3dt5.cloudfront.net/nice-dcv-server-x64-Release.msi', 'nice-dcv-server-x64-Release.msi')"
msiexec.exe /i nice-dcv-server-x64-Release.msi ADDLOCAL=ALL /quiet /norestart /l*v dcv_install_msi.log

reg add HKEY_USERS\S-1-5-18\Software\GSettings\com\nicesoftware\dcv\session-management /v create-session /t REG_DWORD /d 1 /f
reg add HKEY_USERS\S-1-5-18\Software\GSettings\com\nicesoftware\dcv\session-management\automatic-console-session /v owner /t REG_SZ /d administrator /f
reg add HKEY_USERS\S-1-5-18\Software\GSettings\com\nicesoftware\dcv\session-management\automatic-console-session /v storage-root /t REG_SZ /d C:/Users/Administrator/ /f

reg add HKEY_USERS\S-1-5-18\Software\GSettings\com\nicesoftware\dcv\display /v console-session-default-layout /t REG_SZ /d "[{'w':<1920>, 'h':<1080>, 'x':<0>, 'y': <0>}]" /f

reg add HKEY_USERS\S-1-5-18\Software\GSettings\com\nicesoftware\dcv\display /v min-head-resolution /t REG_SZ /d "(1920, 1080)" /f

net stop dcvserver
net start dcvserver
</script>

Optional: Windows auto logon on boot

If you want Windows to auto logon on startup, you can download and run Sysinternals Autologon.

AWS
EXPERT
published 2 months ago700 views