Skip to main content
deleted 8 characters in body
Source Link
Io-oI
  • 8.3k
  • 3
  • 13
  • 41

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 boldbold 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 not [%~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
003:  cls && cd /d "%~dp0"

008:  if /I [%~1]==[debug] set "debug=on"
009:  if /I not [%~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:   )

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 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 not [%~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
003:  cls && cd /d "%~dp0"

008:  if /I [%~1]==[debug] set "debug=on"
009:  if /I not [%~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:   )

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
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:   )
deleted 8 characters in body
Source Link
Io-oI
  • 8.3k
  • 3
  • 13
  • 41

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

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

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

Source Link
Io-oI
  • 8.3k
  • 3
  • 13
  • 41

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 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 not [%~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%\Desktop\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 not [%~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