I recently saw a question in a discussion forum for LoadRunner and after replying with a potential solution for a friend of mine, I thought that I’d share my solution here as well. My friend was testing using a Citrix client and when the script failed, the Citrix client was left running. This meant that subsequent test iterations would all fail as well.
Testers using other thick clients such as SAPGUI, RDP, TruClient (using Firefox or Chrome), QTP or UFT may also face this issue.
One way to resolve the problem of orphaned process such as this would be to use a command line function to kill the offending process when an error is detected. In the example below, the script kills any instance of the “calc.exe” (calculator) process. You should replace “calc.exe” with the name of the executable / rogue process.
N.B. You need to be extremely careful with this code (for obvious reasons).