Super User Asked by Inna Shnaiderman on January 21, 2021
I have a batch file which I need to run every 15 min.
When I click twice on the batch I:
test
to run and It is always Scripttest.jmx
, like this:y
in this SS:I am trying to create scheduled task, and I am doing the following:
But it is not working. How exactly I should write the code in the scheduled task for the scenario as above? Thanks, Inna
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 .ExecutorJMeterRunGen.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%QVScalabilityToolsScriptExecutor<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
Answered by It Wasn't Me on January 21, 2021
Please try to make the following batch file: (Open notepad and paste the following code, then save it as "MyCustomBatch.bat"
)
cd "C:UsersinnashnQVScalabiltiyScriptExecutor"
.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).
Answered by Narzard on January 21, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP