How to change the default resolution in Windows for automatic logon?

I have several Windows Server 2012 virtual systems, mainly on AWS. These systems are used to perform browser based UI tests using Selenium. The tests need to be started with a specific user account, because that user has the UI environment properly configured for running the tests.

To understand the scenario, imagine that you log in to a remote virtual system via e.g. RDP, configure your desktop environment for running the tests, and then you start up the tests and watch them running. So far so good, if I run the tests this way, everything is OK.

In order to automate the whole process, I configured the test clients as Jenkins Slaves. Important note is that I had to start the Jenkins Slave process with the same user account that has the UI environment configured for the tests. This ensures that the proper user account and UI environment is used when I fire up the tests via Jenkins. At the end, I could run the test this way from Jenkins successfully as long as I had the RDP connection open.

The problem is that as soon as I disconnect from the test client, the tests start to fail. It appears that it is required to have an active RDP connection with the specific user account in order to make all the UI tests succeed. This is what I try to eliminate now.

The solution so far seems to be to configure the user account I use for the tests to log on automatically when the test client starts up. To configure the automatic logon I use the Autologon tool, but there are other means as well to achieve the same effect. After system startup my user seems to "log in" successfully, i.e. after bypassing the logon screen it gets its GUI environment initialized with a default 1024x768 screen, also all programs that are defined to start automatically after logon are started successfully, including my Jenkins Slave process.

When I run the UI tests against such test clients via Jenkins, most of the tests complete successfully, except the ones that require a higher resolution than the default 1024x768. This is what I'm trying to find a solution for.

I tried changing the screen resolution with multiple command line tools (like QRes) right after the autologon completes and the Jenkins Slave process starts - with no luck. It seems that without an actual monitor attached, these tools cannot change the resolution. There is this similar question here with some other means to change the default resolution (although non of them seems to work), but please note that in order to make the solution independent of the used virtualization technology, I'm primarily looking for a way to change the default resolution in Windows itself and not via some WMWare or AWS configuration tool.

After googling a bit I only found ways to change the default 1024x768 resolution for custom Windows installation media. This gave me the idea that this 1024x768 default resolution is ingrained somewhere deep but still configurable.

Is there anyone who knows how to change this 1024x768 default resolution for automatic logon? Can anyone suggest who and where else could I ask this question, perhaps there are some forums dealing especially with questions related to such Windows internals?


Solution 1:

I had the same issue when building a Windows Selenium farm for testing at specific resolutions.

Set headless screen resolution on Windows by:

  1. creating a new user called rdp_local
  2. creating a startup script to RDP into the specified user account at specified resolution
  3. adding a firewall rule to open RDP port 3389
  4. configuring 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.

Here is the Chef recipe that does all of the above: https://github.com/dhoer/chef-windows_screenresolution

There is also a chocolatey package as well: https://community.chocolatey.org/packages/screen-resolution