:: This batch file is a wrapper for the Rscript program; it reads the install path of Rscript.exe from RscriptPath.txt

:: Turn off echo so that only error messages will be seen
@echo off

:: If RscriptPath.txt doesn't exist, run the utility to create the file
if not exist RscriptPath.txt call GetRscriptPath.bat
if not exist RscriptPath.txt goto done :: no need to give an error here as GetRscript.bat will already have given an error

:: Read the file
set /p RscriptPath=<RscriptPath.txt
if not exist "%RscriptPath%" goto notvalid

:: Clear the screen and run the program
cls
"%RscriptPath%" %1 %2
goto done

:: The path in RscriptPath.txt is invalid so issue an error, with a pause so that the user can see the error
:notvalid
echo Rscript install path does not exist. Please edit the install path by using the option from the R Support menu.
pause
:done