Search code examples
windowsbatch-filecmdjrepl

Why does JREPL.bat close my batch script?


Here's a bit of a problem I'm having with JREPL.bat.

Whenever I use JREPL in a batch script, it completely shuts down my batch session after running the command. It still replaces text like it's supposed to. But it still closes. Here's the code:

@echo off
cls
@mode 50, 35

:start
cls
echo.
echo.
echo Enter Account Pin:
set /p pin=": "

:: Finding the specified pin
findstr /m "%pin%" %cd%\pins\bin.txt >Nul
if %errorlevel%==0 (
echo Pin "%pin%" is valid
timeout 1 >nul
goto account
)

if %errorlevel%==1 (
echo Pin "%pin%" is invalid
pause
goto start
)

:account
cls

:: Finds the name of the account owner and continues
setlocal
for /F "tokens=2 delims=/" %%a in ('findstr /I "%pin%/" %cd%\pins\bin.txt') 
do set "user=%%a"  
for /F "tokens=3 delims=/" %%b in ('findstr /I "%pin%/%user%/" 
%cd%\pins\bin.txt') do set "balance=%%b"  
echo.
echo.
echo Welcome, %user%.
echo.
echo ACCOUNT BALANCE: $%balance%
echo.
echo 1=Deposit / 2=Withdraw / 3=Exit / 4=Refresh
choice /c 1234 >nul 
if %ERRORLEVEL% EQU 1 goto deposit
if %ERRORLEVEL% EQU 2 echo withdraw & pause
if %ERRORLEVEL% EQU 3 exit
if %ERRORLEVEL% EQU 4 goto account

:deposit
echo.
echo.
set /p add="Money to Add: "
set /a moneytoadd=%balance%+%add%
jrepl "%pin%/%user%/%balance%" "%pin%/%user%/%moneytoadd%" /f 
%cd%\pins\bin.txt /o -
call dial.bat
endlocal

I would like the easiest solution, thank you.


Solution

  • Because jrepl.bat is a batch file.

    To execute a batch within a batch, you need to

    CALL target.bat ...
    

    which provides batch with a return location for when the CALLed batch finishes.