Working with Minimised and Closed Remote Desktop Connections

Minimised Remote Desktop Connection

When tests are executed on a remote machine using Remote Desktop Connection and the RDC window remains minimised, native events (including taking screenshots) fail to work.

To fix this, one needs to add registry keys on the client machine from which the Remote Desktop Connection is made.

danger Registry keys are to be modified only on the client machine and not on the remote machine. Be cautious while changing these registry entries.
  1. Launch Run and write 'regedit' to open Windows Registry on your machine
  2. Find the registry key:
    • HKEY_CURRENT_USER\Software\Microsoft\Terminal Server Client
    • HKEY_CURRENT_USER\Software\Wow6432Node\Microsoft\Terminal Server Client
    • HKEY_LOCAL_MACHINE\Software\Microsoft\Terminal Server Client
    • HKEY_LOCAL_MACHINE\Software\Wow6432Node\Microsoft\Terminal Server Client
    infoNote: If any of the above keys is not present in your system, then just skip that key and proceed further.
  3. Create a DWORD value with the name RemoteDesktop_SuppressWhenMinimized and set its value to 2 in all the above registry key.
  4. Run the tests.
Now native events should work well with a minimised Remote Desktop Connection.

Closed Remote Desktop Connection

Sometimes users would want to open a Remote Desktop Connection, start running the tests on the remote machine, and close off the connection from the client while the tests are running.

In this case, native events (including taking screenshots) fail to work.

To work around this, do the following instead of closing the remote desktop connection directly.
  1. Create a batch file on the Remote machine's Desktop (For example: "disconnect.bat").
  2. Type the following line in the file -

    tscon %sessionname% /dest:console

    Or,

    for /f "skip=1 tokens=3" %%s in ('query user %USERNAME%') do (%windir%\System32\tscon.exe %%s /dest:console)

    and save it.
  3. Start off the tests on the Remote machine.
  4. Do not close the Remote Desktop Connection from the client directly.
  5. Instead, double click on the batch file. The session will be closed by the remote desktop.
Now native events should work well with the closed Remote Desktop Connection.

System on Standby Mode

Sometimes while running the script on Remote Desktop Connection, the client might go to sleep mode because of being in inactive state for some time or from user's action.

In this case, blank screenshots will be captured by the script.

To resolve this issue, follow the steps given below
  1. Start Sahi in your system.
  2. Click on this link
  3. Click on Show All properties button.
  4. Search for the property system.prevent_standby.enabled and change it to true.
Now native events should work well with the closed Remote Desktop Connection.