0

I have a batch file which I need to run every 15 min.

When I click twice on the batch I:

  1. Need to enter the name of test to run and It is always Scripttest.jmx, like this:

enter image description here

  1. Need to enter y in this SS:

enter image description here

  1. After that the batch runs successfully.

I am trying to create scheduled task, and I am doing the following:

enter image description here

But it is not working. How exactly I should write the code in the scheduled task for the scenario as above? Thanks, Inna

3
  • Not sure hot the inline call will work with that scriptsuite, but try making your own batch file with 4 lines. cd C:\QVScalability\ScriptExecutor >> .\ExecuteTests.bat >> Scripttest.jmx >> y double arrows denote a line break. I would type them all in that order in an open cmd window first and if it works, then creating that batch should work
    – Narzard
    Commented Oct 26, 2020 at 13:32
  • Hi, I moved QVScalability to another folder C:\users\innashn. Get the following errors: Commented Oct 26, 2020 at 14:49
  • C:\Users\innashn>QVScalabiltiy\ScriptExecutor 'QVScalabiltiy\ScriptExecutor' is not recognized as an internal or external co mmand, operable program or batch file. This is an error I get for the first row. I moved QVScalability to be on c:/users/innashn. Please advise. Commented Oct 26, 2020 at 14:57

2 Answers 2

0

Please try to make the following batch file: (Open notepad and paste the following code, then save it as "MyCustomBatch.bat" )

cd "C:\Users\innashn\QVScalabiltiy\ScriptExecutor"
.\ExecuteTests.bat
Scripttest.jmx
y

This should change directory to where the executetasks batch file is (line 1) Then it will run that batch file (line 2) and enter the custom commands while auto advancing (line 3 & 4).

1
  • Hi Narzard, I created such batch file, when I tried to run it manually, it poped out the same window as original batch - i.e. to put input of the test file to run. Commented Oct 27, 2020 at 7:30
0

I had the feeling that you need to pass inputs, not exactly arguments.

To confirm I tried to download and verify the tool used in your question.

Then I realized that you are using a bat to call another bat that asks for data input, (not exactly arguments, but input).

In order to propose help in your case, I choose to suggest that you copy the bat file originally used ExecuteTests.bat, renaming it to something like ExecuteTests2.bat, and add the edition of the bold and italic lines below and add the necessary arguments for you to use this in scheduling.


@echo off

cls && cd /d "%~dp0"

setlocal enabledelayedexpansion

:readBatParam
if /I [%~1]==[debug] set "debug=on"
if /I [%~x1]==[.jmx] set "testInput=%~nx1"

:readConfig
REM ## Fetch the PATH of the JMeter binary from the config file ##
REM ## Fetch JVM Heap Size from the config file ##

:JmeterPath
for /f "eol=# tokens=*" %%a in ('FIND "JMeter Installation Path" "config.txt"') do (
  for /f "delims== tokens=2" %%i in ("%%a") do (
    set JmeterPath=%%i
:removeLeftSpace
if "!JmeterPath:~0,1!"==" " set "JmeterPath=!JmeterPath:~1!"&GOTO :removeLeftSpace
:removeRightSpace
if "!JmeterPath:~-1!"==" " set "JmeterPath=!JmeterPath:~0,-1!"&GOTO :removeRightSpace
  )
)

:HeapSize
for /f "eol=# tokens=*" %%a in ('Find "JVM Heap Size" "config.txt"') do (
  for /f "delims== tokens=2" %%i in ("%%a") do (
    set heapSize=%%i
    set heapSize=!heapSize: =!
  )
)

if [%heapSize%]==[] (
set heapSize=3072
)



REM ## Verify the path is correct to avoid error when execute the JMeter binary. ##
:checkJMTpath
dir "%JmeterPath%" | FIND "ApacheJMeter.jar" >NUL
rem echo %errorlevel%
if errorlevel 1 goto :JMTpathError

:start
echo.
echo                Welcome To The Generic Test Suite
echo  **********************************************************************
echo.
echo * The available test script(s) to run :
echo.

REM ## List all .jmx files under .\DestJMXs folder ##
CD .\DestJMXs
for %%a in (*.jmx) do (
  echo   + "%%a"
)

echo.
echo Please choose the test(s) you want to run. You can :
echo . Run ALL test scripts by entering '*'. 
echo . Run A single test script by entering the file name.
echo . Run a GROUP of test scripts sharing the common text in file name by  
echo   entering 'TEXT*' (replace the TEXT part with the common text).
echo . EXAMPLES: -  "*";  "Films";  "Fi*" .
:selectTest
echo.
if /I Not "%testinput%" == "%~nx1" ( 
     set testInput=
     set /p testInput=Enter the TEST(s) you want to run :
    )
    
IF /i "%testInput%" == "" GOTO :selectTest
REM ## Remove empty space from the input, to avoid JMeter execution error. ##
  for /f "delims=. tokens=1" %%i in ("%testInput%") do (
    set testInput=%%i
    set "testInput=!testInput: =!"
  )
IF /i "%testInput%" == "" GOTO :selectTest

REM ## Check the input file name are existing, to avoid the execution error. ##
:checkTest
echo.
echo * The test script(s) you have chosen :
echo.
for %%a in (%testInput%.jmx) do (
  echo   -"%%a"
)  
echo.
DIR %testInput%.jmx >NUL
rem echo %errorlevel%
if errorlevel 1 goto :404Error

:confirmTest
if /I not  "%~2" == "y" ( 
     set confirmInput=
     set /p confirmInput=   DO YOU WANT TO PROCEED? : [Y/n] 
    ) else (
     IF /i "%confirmInput%" == "" GOTO :executeTest
     IF /i "%confirmInput%" == "Y" GOTO :executeTest
     IF /i "%confirmInput%" == "N" GOTO :selectTest
  )
    
:executeTest
rem setlocal disabledelayedexpansion
CD ..
SET wdir="%cd%\DestJMXs"
for %%a in (DestJMXs\%testInput%.jmx) do (
  rem echo "%%a"
  set testName=%%a
  start "JMeter Test Window" call .\Executor\JMeterRunGen.bat
  timeout /t 2 /nobreak >NUL
)
pause

:end
GOTO:EOF

:JMTpathError
echo.
echo                             xxxxxxxx
echo                               ERROR
echo   Can not find "ApacheJMeter.jar" file under the path you input:
echo   "%JmeterPath%". 
echo   Please check the setting in your "config.txt" file.
echo.
pause
GOTO:EOF

:404Error
rem echo.
echo ERROR: Please check your file "%testInput%.jmx" exists in ".\DestJMXs\" directory.
pause
GOTO:EOF

Obs.: 1 The answer is considering that the bat file in which you will use the input is: %UserProfile%\QVScalabilityTools\ScriptExecutor<b>ExecuteTests2.bat

Obs.: 2 The lines where editions took place are suggested respectively are:

003:  cls && cd /d "%~dp0"

008:  if /I [%~1]==[debug] set "debug=on"
009:  if /I [%~x1]==[.jmx] set "testInput=%~nx1"

069:  if /I Not "%testinput%" == "%~nx1" ( 
070:       set testInput=
071:       set /p testInput=Enter the TEST(s) you want to run :
072:      )

096:  if /I not  "%~2" == "y" ( 
097:       set confirmInput=
098:       set /p confirmInput=   DO YOU WANT TO PROCEED? : [Y/n] 
099:       ) else (
100:        IF /i "%confirmInput%" == "" GOTO :executeTest
101:        IF /i "%confirmInput%" == "Y" GOTO :executeTest
102:        IF /i "%confirmInput%" == "N" GOTO :selectTest
103:   )

Obs.: 3 The edits made your bat use the %~1 and %~2 arguments, where respectively they will be used in the relevant inputs:

..\ExecuteTests2.bat Scripttest.jmx y

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .