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

6

3

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?

remark

Posted 2014-12-16T13:42:21.733

Reputation: 71

2Are your users connecting via RDP, or something else? – Rowland Shaw – 2014-12-16T14:15:04.460

Possible Duplicate (no answers yet): Set Windows Server 2012 default screen resolution (VM Ware)

– Ƭᴇcʜιᴇ007 – 2014-12-16T15:06:58.947

@Rowland Shaw The users are not connecting in any way, they are just logged in automatically (i.e. bypassing the password screen). I assume this is the same functionality that you get when you configure a physical PC with the option not to ask for password at startup. Then when you switch on your PC you go all the way to the Windows desktop. Same happens now, but this is a VM - as my assumption goes (since I don't understand the internals of this Autlogon tool/functionality). – remark – 2014-12-16T15:14:15.047

@Ƭᴇcʜιᴇ007 Yes, this is a duplicate, now I see. Thanks for pointing it out! – remark – 2014-12-16T15:15:56.067

@climenole No luck with QRes: it says "The graphics mode is not supported!" – remark – 2014-12-16T15:26:37.973

How can they see the desktop if they're not connecting, and there's no monitor attached? – Rowland Shaw – 2014-12-16T16:02:56.447

@Rowland Shaw As as mentioned, the systems are used for automated UI testing. They are booted, a default user is automatically logged in (using Autologon), then this user starts up a Jenkins Slave. Once this is ready, from Jenkins Master tests can be executed on this client, and since the Jenkins Slave is started by the user that is autologged, this user's GUI will be used for the autotests. I hope it is clearer now. So no real user will do anything on the client or see anything on the screen, it is an all-automated infrastructure, where only UI tests are run automatically. – remark – 2014-12-16T16:15:39.937

If it is not a big favor to ask, I would like to know why this question was downvoted apart from not realizing that it is a duplicate. I really try to understand to prevent future downvotes, so please explain. – remark – 2014-12-16T16:18:10.213

Answers

2

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

Dennis Hoer

Posted 2014-12-16T13:42:21.733

Reputation: 131

thanks a lot, I can confirm it does work (windows server 2008 r2 + selenium). I did not use the Chef recipe, as it seems to be too heavy. The idea is to use rdp_local to trigger the actual start up script via the remote connection. And though rdp_local itself got resolution of 1024x768, but it could try to enforce a higher resolution using the RDP. – Walty Yeung – 2017-08-08T08:59:26.000

The registry settings in the chef script didn't work for me. Group policy constantly got in the way so I decided to use the open source client FreeRDP since it isn't restricted by group policy. Worked like a charm. Other than that, everything else worked great. – chrisdrobison – 2017-11-14T12:39:30.633

0

We were in exact situation with selenium on a VM running on the cloud.

I was able to resolve the issue by connecting to the console session of the VM (so as to not invoke any rdp context) and just setting the default resolution for the user and system. after that all worked.

hollow

Posted 2014-12-16T13:42:21.733

Reputation: 1

Hi @hollow, I have been trying to connect to the console session on an EC2 Windows VM but no success. I have tried "mstsc /admin", "mstsc /console" but nothing worked. Can you please share how you did it? – Sagar – 2017-10-05T17:33:03.683

0

You can setup default Desktop Resolution once, and it will be persistent, no need to have some scripts execute every startup.

You will need to:

  1. Connect to the server using TeamViewer or TightVNC (anything that does not force its own resolution).

  2. Change resolution as you normally would, and all done.

alandarev

Posted 2014-12-16T13:42:21.733

Reputation: 101