LoadRunner and Performance Center
Showing results for 
Search instead for 
Do you mean 

4 Tips for Replaying Remote Desktop Protocol (RDP) scripts in LoadRunner

Anonymous_User1 ‎05-09-2013 11:14 PM - edited ‎09-22-2015 01:35 PM

LoadRunner scripts that use the Remote Desktop Protocol (RDP) don’t always replay smoothly.  My colleague Kert (Yang Luo) from the LoadRunner R&D team has collected some tips that will save you time and effort, and help you ensure that your RDP scripts run correctly.


You can download HP LoadRunner here to experience it for yourself.


Tip #1: Sync for image before keyboard event

Sometimes the Virtual User (Vuser) script needs to send some keyboard event to the remote machine. One such example is sending the username and password during the login phase. However, during replay the script tends to run much faster than a manual interaction. So it's quite possible that the keyboard event is sent before the target control appears and is ready to accept input.


When a connection is established while recording a login scenario, the user types the username directly after the login screen appears. This means that during the replay, the rdp_type step is executed immediately after the rdp_connect is completed, which might be before the credentials screen has event appeared. So the “typing” will begin before its target control is visible, the username received at the server side will be incorrect (e.g. “strator” instead of “administrator”), the login process will fail and the client side will get a “Connection Reset” message.


The way to avoid the issue is by adding a sync_on_image step immediately before the rdp_type events. This way we can make sure the expected control appears before the typing begins. In fact, the generated script usually contains such a warning comment about it, but it is often ignored or overlooked:


/* This script contains keyboard steps without automatic synchronization.
    Consider adding a synchronization step before the relevant keyboard steps.*/

The sync_on_image step can be added manually by right-clicking on the snapshot. You can also perform a dummy mouse click on the target control before typing. That will add rdp_sync_image and rdp_mouse_click steps automatically:




Tip #2: Use rdp_sync_* functions to emulate think time 

In RDP scripts the think time is ignored by default:


This means that the script doesn’t pause during the replay. Sometimes users need to wait for a very long time during some time-consuming initialization at the server side, so they'll enable think time and add an lr_think_time step with a sufficiently large value .  But this has potential problems. 


During the execution of the lr_think_time, the client side appears 'frozen' and will not communicate with the server in any way. So from the server's point of view, the client is non-responsive. If the lr_think_time is longer than the server's tolerance, the server will end the connection, causing the replay to fail.


The solution is to remove the lr_think_time, and use rdp_sync_* functions (such as rdp_sync_image, or rdp_sync_on_window) instead. The rdp_sync_* functions have a "timeout" parameter, and you just need to assign a large enough value to it:



Tip #3: Use rdp_save_image for troubleshooting

An RDP script is difficult to debug because the protocol is image-based. When the script fails on some rdp_sync function, it's hard to understand what happened from the log alone.


The solution is to add an rdp_save_image step before or after the problematic step. This function will save the current screenshot to a file and show what happened at the server side.


Here's an example:


If ( LR_PASS!=rdp_sync_on_image(<parameters>,FailIfNotFound=No,RDP_LAST) )


Tip #4: Ensure licenses for Remote Desktop Service (aka Terminal Service) are available before replaying the script

Remote Desktop Service (formerly known as Terminal Service) is an enhanced version of RDP available in Windows Server Systems (Windows 2003, Windows 2008 etc.), which supports multiple concurrent sessions. However, it also requires an extra fee, as the client side must have a terminal service license in order to connect to a terminal server.


LoadRunner can retrieve Terminal Service license information from the client machine’s registry (assuming the license info is already there), and use that license to connect to the Terminal Service server. However, if the client side license is missing or expired, the RDP script replay will fail. In this case, launch the Microsoft RDP client (MSTSC.exe) and connect to the TS server manually first, so that the new/updated license is retrieved and stored in the registry.


Note: Terminal Service license support was added in LoadRunner 11.52.




Many thanks to Kert (Yang Luo) from LoadRunner R&D for providing this article.


Click here to learn more about HP LoadRunner components


You can download HP LoadRunner for yourself here.

About the Author


on ‎11-04-2013 12:43 AM

Useful article.


Many thanks.

on ‎11-04-2013 01:30 AM

Thanks for your feedback, GoodNeil!

on ‎03-18-2014 06:42 AM



That was really nice tips :). Do you have some more  ?




on ‎09-07-2014 09:10 PM

Thanks a lot and which is very usful one ---Before start working on RDp protocol.


With out this might be will not have solution.


Thanks A lot once again..!

on ‎05-04-2016 09:37 AM

I would like to run 50 RDP users from Controller. 

Would it require 50 remote machine be available during my test?

Any help is appreciated. 



27 Feb - 2 March 2017
Barcelona | Fira Gran Via
Mobile World Congress 2017
Hewlett Packard Enterprise at Mobile World Congress 2017, Barcelona | Fira Gran Via Location: Hall 3, Booth 3E11
Read more
Each Month in 2017
Software Expert Days - 2017
Join us online to talk directly with our Software experts during online Expert Days. Find information here about past, current, and upcoming Expert Da...
Read more
View all