Friday 21 June 2013

Set up LoadRunner to run nightly

To get LoadRunner to run nightly required two things. The first was a batch file that would execute LoadRunner and then invoke the analysis and the second was how to schedule the execution on the controller.

The batch file to run LoadRunner at night and to save the results in a specific directory for that nights run is shown below:REM Batch to run nighlty performance test REM REM Thanks to Simon Shepard at http://www.ss64.com for date code REM Calculate today date FOR /f "tokens=6-8 delims=/ " %%G IN ('NET TIME \\%computername%') DO ( SET _mm=%%G SET _dd=%%H SET _yy=%%I ) REM Run LoadRunner "C:\...\bin\Wlrun.exe" -Run -TestPath "P:\Projects\...\PeakHourSmall.lrs" -ResultLocation "P:\...\Results" -ResultCleanName Night-%_dd%-%_mm%-%_yy% REM Run analysis "C:\...\bin\AnalysisUI.exe" -RESULTPATH "P:\...\Night-%_dd%-%_mm%-%_yy%\Night-%_dd%-%_mm%-%_yy%.lrr"

To get the batch file to run as a scheduled task took longer than expected due to some restriction on the PC at work. To overcome this I had to use schtask.exe to schedule the batch.schtasks.exe /create /SC daily /ST 01:50:00 /TR "P:\...\Nightly.bat" /TN RunPerfTest

The nightly LoadRunner test now runs at 1:50 in the morning and the results are waiting when I arrive in the morning.