Skip to main content

LoadRunner to Performance Center Migration tips #4 - HOSTS files

****UPDATED****See Floris Kraak's comments below, he has a much more elegant solution.......****UPDATED****It is common practice for testers to use local HOSTS files to direct traffic from Load Generators to the application under test. If possible the URLs should be parameterised, this allows the URLs to be changed quickly, for example when switching between development and test environments. Some web servers, however, host multiple websites and direct traffic to the appropriate site using host headers. If this is the case you can't do this and you may need to change the HOSTS files on the load generators.Because load generators can be assigned to a test at "run time" using Performance Center, there may be a requirement to change HOSTS files at "run time". The method below explains how you can do this. The sample script is available for download if required. The sample script includes output messages as well as think time which may help you to confirm that it is working properly before you use it.

Script adapted from one described in the HP Performance Center discussion group.In order for this script to work you need to do one of the following  to allow the HOSTS file to be changed by the script.:VUGENRun VUGEN as an administrator**(Not just logged in as an administrator - Right-click the shortcut and choose the "run as administrator" option.)ControllerRun Controller and the LoadRunner Agent (if running as a process) as an administrator (using same technique as for VUGEN).Disable UACAlternatively if you are using administrative accounts and don't want to go to the trouble of running everything "as an administrator" too. You can disable UAC.On my test PC (using Windows 7), I did this by making a registry change, alternative techniques for disabling UAC are described by "MyDigitalLife".Alternatively HOSTS files should be maintained by a single admin allowing them to be managed centrally and pushed out to load generators as required.


I'm sorry, but this definitely how you should *not* solve that particular problem.

The easiest way to solve this in web scripts is a single call:

web_add_auto_header("Host", "");

And then simply use the IP address in the various web_url() and web_custom_request() calls.

That should suffice for 99% of the cases involving the web protocol. If not more of them.

Add new comment

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.
Enter the characters shown in the image.