(I debated between posting this here, ServerFault, and StackOverFlow. Settled for this. Hopefully it's in the right place.)

We run our UI testing suite using Selenium Grid 2 with an Amazon EC2 Windows machine (that is started up in using Amazon's CloudFormation APIs). My question is, how do I change the resolution of that machine?

If I remote into it, I can specify the resolution using Remote Desktop. But obviously that doesn't permanently change the resolution. When we run our tests, the resolution is so small that the browser scrunches the elements together and causes the tests to fail.

Any ideas? Is there something I can put in the CloudFormation recipe? Is there something I can do to the image before creating the AMI?

Screenshot of Device Manager


  • 1
    Interesting. It must be a standard instance I imagine, so no CUDA graphics cards assigned to the instance. So you are working with a standard virtual graphics card. What does it look like in device manager? Can you post a screenshot? You may be able to force it higher by rdp-ing to the console: mstsc.exe /console – Paul Apr 19 '12 at 23:59
  • @Paul, I added a screenshot. It is a standard instance. Windows Server R2. Thanks. – Joel Apr 20 '12 at 14:45
  • @Joel, did you ever resolve this? I've been trying to find ways to do this for several days, including using the answers below, but no luck so far. On reboot, or creation from AMI (even ones that have had the answers applied to them), they still start in 1024x768. – Sean Aug 14 '14 at 16:36

Disclaimer: TightVNC is not secure, so if security is an issue, you may need to find a different approach. The whole process will take only a few minutes, so the security hole is small, but there nonetheless.

  1. Install TightVNC Server on the EC2 instance so you can log into the console
  2. Disconnect all user remote desktop sessions and return the session to console
  3. Use the TightVNC Viewer to log into the EC2 instance console, ensuring port 5900 is open for that connection
    • Right-click on the desktop and select "Screen resolution"
    • Select "Advanced settings"
    • Select "List All Modes"
    • Select a higher resolution
  • This did allow me to change my resolution, which I believed would fix my real problem, however it did not. My selenium tests that are running automated on my windows 2008 ec2 server via task scheduler are still running at a small resolution. Even after updating with the above, they are running at a smaller resolution. Yes, the windows are set to maximize resolution in the selenium configuration. – Copy and Paste Jan 16 '18 at 18:57

You can change the screen resolution by modifying two registry values. These two values are: HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Video\GUID\0000\DefaultSettings.XResolution HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Video\GUID\0000\DefaultSettings.YResolution Where GUID is a randomly generated GUID.

You can actually specify any XResolution and YResolution value as long as they are hexadecimal.

Note: In the case of a CRT monitor specifying an absurd resolution might damage your monitor. In the case of a LCD monitor your monitor might not show any user interface anymore. A good way to change your Screen resolution is to write down the amount of pixels you want to fill your screen width with (this is the XResolution) and the amount of pixels you want on your screen height (the YResolution). The Windows calculator (not available in Server Core , you will have to find another computer or a hardware advanced calculator) offers an easy way to convert decimal amounts to hexadecimal amounts. You can then use these values to modify the corresponding registry values. A restart will make your preferred screen resolution meet reality.

The color depth used on your monitor is captured in the following registry value: HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Video\GUID\0000\DefaultSettings.BitsPerPel On my box this hexadecimal value was set to 0x00000008 (8) which meant my screen used an 8 bit color depth. (256 colors) Changing it to 16 bits (0x00000010) will show 65536 colors (High Colors) Other values that are typically available are 24 bits (0x00000018) and 32 bits (0x00000020).


  • I don't have the DefaultSettings.*Resolution keys in any of the GUID.0000. I think it's because it only has virtual devices. Can I add that key to each of them? Would that work? – Joel Apr 20 '12 at 14:42
  • @Joel: I doubt it. Isn't there a 'Video' branch at all? I have a Server Core 2008 R2 instance on EC2, so I'll have a look at it this evening. – paradroid Apr 20 '12 at 15:22
  • Yeah, didn't think so. Thought I'd ask anyway. I'll keep looking for solutions. Let me know if you find anything. Thanks. – Joel Apr 20 '12 at 16:02
  • I also do not have the DefaultSettings.* in my registry. I couldn't even attempt this solution. It appears it could help some, just not all. – Copy and Paste Jan 16 '18 at 18:58

I was able to get this working using a combination of @kenny-trytek 's answer above and setting up auto login.

I think the VNC resolution only gets set for the current user, so setting up auto-login ensures that this user has an open session.

Setup auto login https://support.microsoft.com/en-us/kb/324737

Next, in the users Start Up folder provide a shortcut or bat file to kick off the selenium node process.

  • 1
    Please quote the essential parts of the answer from the reference link(s), as the answer can become invalid if the linked page(s) change. – DavidPostill Jul 21 '16 at 8:24

I tried all most all above and failed. Found a solution unique for my situation which was simple ..use windows power-shell.

wrote power-shell script

Set-DisplayResolution -Width 1920 -Height 1080 -Force

name it resolution.ps1

saved in C:\myTestFolder

and run it from command line like below..... (my scripts are driven by batch files)

WindowsPowerShell\v1.0\powershell.exe C:\myTestFolder\resolution.ps1

Here is how I set the headless screen resolution on AWS Windows using RDP:

  • create a new user called rdp_local
  • create a startup script to RDP into a specified user account (e.g. selenium) at specified resolution
  • add a firewall rule to open RDP port 3389
  • configure auto-logon to login as rdp_local on reboot

Note that auto-logon requires a username and password and that the password is stored unencrypted under windows registry HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon.

Tested on Amazon Windows Server 2012 R2 AMI.

Here is a Chef cookbook that does the above: https://github.com/dhoer/chef-windows_screenresolution


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.