NOTICE: Branded Content
NOTICE: Certain versions of content (“Material”) accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.
LoadRunner User Discussions
cancel

How to invoke multiple batch files from LoadRunner

Highlighted
Soumya Contributor.
Contributor.

How to invoke multiple batch files from LoadRunner

Hi,

I want to invoke multiple batch files from  the load runner. Can someone suggest on the approach to do that.

I have tried to parameterize batch filenames and pass them to the System function but it is not working.

Looking for the suggestions ASAP.

 

 

 

4 REPLIES
 Honored Contributor... orenga  Honored Contributor...
 Honored Contributor...

Re: How to invoke multiple batch files from LoadRunner

Hi

It's works for me with system command :     system("C:\\1.bat");

I attach also a screenshot .

Maybe you have any permission  issue to open CMD ,

try launch VuGen as Administrator .

 Oren

 

bat.jpg

 

JHF Remmelzwaal Honored Contributor.
Honored Contributor.

Re: How to invoke multiple batch files from LoadRunner

In addition to Orens reply,

When you want to invoke the batch files in background (do not wait till the batch file completes) use the command:

    system("%ComSpec% /C start /B action.bat");

Put your action.bat in your script directory, add it to Extra Files (else it is not transferred to your Load Generator).

End your action.bat with the command 'exit' to close the command window. There is no need to parameterize your batch file names. It will make things more complicated. You might just use arguments for your batch file:

system(lr_eval_string("%ComSpec% /C start /B action.bat {ARG1}"));

My action.bat looks like

:: Content action.bat
echo %1
pause
exit

 

Soumya Contributor.
Contributor.

Re: How to invoke multiple batch files from LoadRunner

Hi Orenga,

My requirement is to invoke a unique bat file for each iteration and respective user.

Thanks
JHF Remmelzwaal Honored Contributor.
Honored Contributor.

Re: How to invoke multiple batch files from LoadRunner

You have to have all the batch files available on your system or in your LR script directory.

Accoding the documentation is there no evaluation of arguments on the system() call. So you have to code something like:

system(lr_eval_string("batch_{vuserId}_{iteration}.bat"));

to run the batch files from LR script directory. Prepend a fixed path if you store your batch files on a different location, like in the example of Orenga.

Note that you have to maintain that path on your Load Generator and on your VuGen system.

When you add the batch files to your LR script directory, you have to add those bat-files to the 'Extra Files' section in your Solution tree else they are not transferred to your Load Generator, but if that will be a couple of hunders of files that will not work. You might put them in a zip file, add the zip file to the 'Extra Files' section and extract it with a power shell script (PS has a unzip api). An other way is to have one batch file and use the user and iteration number as arguments in the batch file and based on that select the proper actions.

When this information does not solve your problem, please describe your approach in detail and what is going wrong.