See Floris Kraak's comments below, he has a much more elegant solution.......
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.:
Run VUGEN as an administrator*
*(Not just logged in as an administrator - Right-click the shortcut and choose the "run as administrator" option.)
Run Controller and the LoadRunner Agent (if running as a process) as an administrator (using same technique as for VUGEN).
Alternatively 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.