Problems with Remote Desktop

Ask general questions here.
cpalex
Posts: 38
Joined: Sat Feb 17, 2018 12:37 am

Problems with Remote Desktop

Post by cpalex » Wed Dec 12, 2018 5:50 pm

We recently got our test machine in our data center set up, but I have been having some issues getting it to work correctly.

First, it appears as if the setting in Ranorex Agent, "Keep Session Active", doesn't actually keep the section active. Running a test after closing the RDP session returns blank screen shots.

My second attempt was to use the old batch file technique from the FAQ:

https://www.ranorex.com/help/latest/ran ... emote-faq/

And while that doesn't lock the screen, the screen resolution is changing to 544x600, which is far too small for our AUT.

After some research, it appeared that I simply needed to change the default resolution. So I followed the instructions here:

https://social.msdn.microsoft.com/Forum ... forWindows

But the resolution is still being set to 544x600. I went ahead and changed ALL DefaultSettings.XResolution and DefaultSettings.YResolution in my registry to be 1920x1080, but it is still resetting to 544X600.

My current workaround is to disable the lock when RDP is minimized, described here:

https://docs.telerik.com/teststudio/kno ... imized-rdc

Which seems to work, for now.

But with the scale we are looking at, I would really like to be able to not have an RDP session active on some machine in order to run tests.

So, question one, is there a reason the "Keep Session Active" may not be working?

And even if I get that working, I have a feeling I'll run into question number two, how do I set the resolution when using the batch file to keep the session open?

Tolga
Posts: 4
Joined: Tue Oct 16, 2018 2:52 pm

Re: Problems with Remote Desktop

Post by Tolga » Fri Dec 14, 2018 2:09 pm

We have the same situation. We just fire up a VNC-Connection for every VM and leave the Session to itself.
Obviously you have to disable the Windows Lockscreen if it is Idle for x minutes...
But it works and we do not have to use (unsecure) RDP-Sessions.

If you want to do work on the VM --> go for RDP.
If you want to let the VM work through the agent or jenkins --> go for VNC.

The main problem is: Windows tries to save energy. And there is (i guess) no key in the registry where you can tell Windows: "stop shutting down the GUI no matter what!!!"

Vega
Posts: 222
Joined: Tue Jan 17, 2023 7:50 pm

Re: Problems with Remote Desktop

Post by Vega » Mon Dec 17, 2018 6:38 am

I have not personally had any issue with the keep session alive feature, so it may be possible that you have a group policy or security solution in place which is force locking the work station. I would recommend using Agent over RDP for execution if possible, as I have had RDP introduce artificial latency in the past which affected my tests among other issues. What happens when you deploy your test to the Agent (unlocked/active user session) but never RDP in?

cpalex
Posts: 38
Joined: Sat Feb 17, 2018 12:37 am

Re: Problems with Remote Desktop

Post by cpalex » Wed Dec 19, 2018 9:32 pm

Vega wrote:
Mon Dec 17, 2018 6:38 am
What happens when you deploy your test to the Agent (unlocked/active user session) but never RDP in?
It runs the test, but it fails. The returned screen shots are blank, like the user interface was not active.

These are virtual machines, so I have no way to log in without RDP at the moment

Vega
Posts: 222
Joined: Tue Jan 17, 2023 7:50 pm

Re: Problems with Remote Desktop

Post by Vega » Thu Dec 27, 2018 6:48 pm

Blank screenshots are usually an indicator that the user session is locked as you mentioned. I understand having to RDP into the machine for normal access, but once you have Agent setup you will be able to execute your tests without RDP. If the session is still being locked even with both the Agent setting and the old keep alive script, then I am leaning towards a security policy or application locking the system. I would definitely check with your IT staff to see if this is the case.

Please keep us updated!

Hope this helps

Suchy
Posts: 2
Joined: Fri Nov 10, 2017 3:31 pm

Re: Problems with Remote Desktop

Post by Suchy » Fri Jan 18, 2019 2:09 pm

I'm running Ranorex tests on TeamCity agent and solved this issue. No active RDP needed to run tests, but you need to cofigure your VM for auto login and keeping the desktop alive.

1. Set your VM to auto-login on whatever account you use to run tests on:
- start regedit and go to: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon
- Set: AutoAdminLogon = 1
- Set (or add new String Value, if doesn't exist): DefaultUserName = <domain>\<username>
- Set (or add new): DefaultPassword = <pass>

2. Set screen resolution in Registry:
-go to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Video\{<GUID>}\0000, change DefaultSettings.XResolution to 780 (hex) and DefaultSettings.YResolution to 438 - this will set 1920x1080

3. Create a stay-awake PowerShell script and schedule it to start on logon:

Code: Select all

#!/usr/bin/env powershell

# This script can keep the computer awake while executing another executable, or
# if no executable was passed in, then it stays awake until this script stops.
# There are 3 different ways of staying awake:
#     Away Mode - Enable away mode (https://blogs.msdn.microsoft.com/david_fleischman/2005/10/21/what-does-away-mode-do-anyway/)
#     Display Mode - Keep the display on and don't go to sleep or hibernation
#     System Mode - Don't go to sleep or hibernation
# The default mode is the Display Mode.
# Away mode is only available when away mode is enabled in the advanced power options.
# These commands are advisory, the option to allow programs to request to disable
# sleep or display off is in advanced power options.
# The above options will need to be first enabled in the registry before you can
# see them in the advanced power options.
# An alternative to this script is using presentation mode, but this is more flexible.

param (
    [string]$Executable = $null,
    [ValidateSet('Away', 'Display', 'System')]$Option = 'Display'
)

$Code=@'
[DllImport("kernel32.dll", CharSet = CharSet.Auto,SetLastError = true)]
public static extern void SetThreadExecutionState(uint esFlags);
'@

$ste = Add-Type -memberDefinition $Code -name System -namespace Win32 -passThru

# Requests that the other EXECUTION_STATE flags set remain in effect until
# SetThreadExecutionState is called again with the ES_CONTINUOUS flag set and
# one of the other EXECUTION_STATE flags cleared.
$ES_CONTINUOUS = [uint32]"0x80000000"
$ES_AWAYMODE_REQUIRED = [uint32]"0x00000040"
$ES_DISPLAY_REQUIRED = [uint32]"0x00000002"
$ES_SYSTEM_REQUIRED = [uint32]"0x00000001"

Switch ($Option) {
    "Away"    {$Setting = $ES_AWAYMODE_REQUIRED}
    "Display" {$Setting = $ES_DISPLAY_REQUIRED}
    "System"  {$Setting = $ES_SYSTEM_REQUIRED}
}

try {

    Write-Host "Staying Awake with ``${Option}`` Option"

    $ste::SetThreadExecutionState($ES_CONTINUOUS -bor $Setting)

    if ($Executable) {
        Write-Host "Executing Executable"
        & "$Executable"
    } else {
        Read-Host "Enter or Exit to Stop Staying Awake"
    }

} finally {

    Write-Host "Stopping Staying Awake"
    $ste::SetThreadExecutionState($ES_CONTINUOUS)

}
Alternatively you can use some existing tools that prevent sleep, like Insomnial. Just be aware that some of these tools work via pressing a virtual key once in a while, this can screw up your test if it fills up a form or something at the moment.

4. Disable Lock Screen: https://www.windowscentral.com/how-disa ... ock-screen

5. Reboot and enjoy :)

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 7470
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Problems with Remote Desktop

Post by odklizec » Fri Jan 18, 2019 2:17 pm

Hi,

I would recommend tool called LogonExpert. I'm using it a it works quite well.
https://www.logonexpert.com/
You can set it both to auto logon the machine, keep it logged in and unlocked.
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

User avatar
Stub
Posts: 515
Joined: Fri Jul 15, 2016 1:35 pm

Re: Problems with Remote Desktop

Post by Stub » Fri Jan 18, 2019 4:36 pm

I also use LogonExpert after receiving a tip about it here. I've linked it to our MSBuild-based build system so we can automate building of the Ranorex solution, unlocking of the desktop, and relocking of the desktop once complete.

cpalex
Posts: 38
Joined: Sat Feb 17, 2018 12:37 am

Re: Problems with Remote Desktop

Post by cpalex » Tue Jan 22, 2019 3:39 pm

Update with the solution I found for my setup!

I gave up using Remote Desktop. We have a screen connect setup that allowed me to log into our virtual machine like I had a monitor connected.

But the big problem was screen resolution. My VM wouldn't let me set a resolution high enough for my AUT.

So I followed these instructions:

https://kb.vmware.com/s/article/1003

And voila! The remote session stays active, and I get the resolution I need.

Basically, forget RDP. It's too much trouble.

Johann
Posts: 23
Joined: Fri May 03, 2019 8:55 am

Re: Problems with Remote Desktop

Post by Johann » Mon Jun 03, 2019 2:06 pm

I just came across the above problem.

Testsystem:
Windows Server 2016 VM on a Hyper-V server.
I'm starting the Ranorex Agent with a batch script.

The tests work with minimized RDP ( my Resolution 1920 x 1200) but not with closed RDP (1024 x 768). With logged out user (1920 x 1200) but got a black screen on Report...

I tried almost all the tips I found in the forum and online and couldn't fix the problem with the 1024 x 768 resolution.

Unfortunately I am not allowed to install any additional software, so I could not test this possibility. And I can't switch to VMware either…

Anyone have an idea?

Vega
Posts: 222
Joined: Tue Jan 17, 2023 7:50 pm

Re: Problems with Remote Desktop

Post by Vega » Tue Jun 04, 2019 3:41 pm

Johann wrote:
Mon Jun 03, 2019 2:06 pm
Testsystem:
Windows Server 2016 VM on a Hyper-V server.
I'm starting the Ranorex Agent with a batch script.

The tests work with minimized RDP ( my Resolution 1920 x 1200) but not with closed RDP (1024 x 768). With logged out user (1920 x 1200) but got a black screen on Report...

I tried almost all the tips I found in the forum and online and couldn't fix the problem with the 1024 x 768 resolution.

Unfortunately I am not allowed to install any additional software, so I could not test this possibility. And I can't switch to VMware either…

Anyone have an idea?
It sounds like you may have a security policy forcing the session to lock as Agent should keep it open. You can also try this batch script but if you do have a security policy forcing the session to lock after RDP disconnect, then the script likely will not work either:

https://www.ranorex.com/help/latest/ran ... otesession

Johann
Posts: 23
Joined: Fri May 03, 2019 8:55 am

Re: Problems with Remote Desktop

Post by Johann » Wed Jun 05, 2019 8:31 am

I tried this script already it doesn't work for me.
It should be possible to set some configurations in registry to set the default resolution. I tried a lot, but nothing found till jet.
The Firewall is disabled, and we don't have Special security Setups. My test are runing in a dedicated Network, no Internet or connection to othes networks.

Vega
Posts: 222
Joined: Tue Jan 17, 2023 7:50 pm

Re: Problems with Remote Desktop

Post by Vega » Thu Jun 06, 2019 8:22 pm

Johann wrote:
Wed Jun 05, 2019 8:31 am
I tried this script already it doesn't work for me.
It should be possible to set some configurations in registry to set the default resolution. I tried a lot, but nothing found till jet.
The Firewall is disabled, and we don't have Special security Setups. My test are runing in a dedicated Network, no Internet or connection to othes networks.
Came across the below; not sure if you have already seen these:

https://docs.microsoft.com/en-us/powers ... w=win10-ps
https://community.spiceworks.com/topic/ ... resolution

Hope this helps

Johann
Posts: 23
Joined: Fri May 03, 2019 8:55 am

Re: Problems with Remote Desktop

Post by Johann » Tue Jul 02, 2019 8:06 am

I've tried all these solutions, but I'm not sure which solved the problem. Changed many entries in the registry. Something changed the resolution to only 1920x1080, but it's good enough for now....

dvd24
Posts: 4
Joined: Mon Jul 22, 2019 2:46 pm

Re: Problems with Remote Desktop

Post by dvd24 » Tue Oct 29, 2019 1:55 pm

Hi all,
I have approximately the same issue. When i disconnect to the Remote machine , my tests failed due to screen resolution.

1) I run my tests cases and just behind i run as an administrator the file KeepSessionOpen.bat.

2) On my video report , i saw that my screen resoultion has been changed (reduced) automatically, and that's the main reason that my tests failed..

For additonnal information, in all my tests cases, i get a SETUP where i open the browser of the web application; and at the end i close it throught the TEAR DOWN.

Can anyone help me, because i run my test on a remote VM (win10)?

Error: Your DPI settings are limiting object recognition. Set the scaling of all connected monitors to 100 %.
(This message is only shown once per report.)

(https://www.ranorex.com/help/latest/ran ... otesession)