Hello,
The R.exe is the windows executable that will launch R and its graphic interface so you can work with it (that's what happens when you click the shortcut on your windows desktop for example)
The Rscript.exe will take an existing script, run R in the background, execute the script and close afterwards. There is no graphical interface opened and no other human interaction needed.
If you're planning to execute an R script in batch as part of a longer pipeline (so without opening R interface), you need to use the Rscript.exe and a script you've written beforehand.
In this example, a batch script will provide an R script a folder path and a number, and R will generate a csv file in that folder with the specified number of random numbers.
R script (saved in C:/myRscript.R)
#!/usr/bin/env Rscript
#Assign the arguments passed from the batch file to R variables
args = commandArgs(trailingOnly = TRUE)
outputFolder = args[[1]]
value = as.integer(args[[2]])
#Run the R code
print("Start the R code")
myData = data.frame(random = runif(value))
write.csv(myData, paste0(outputFolder, "randomNrs.csv"), row.names = F)
Batch file (shell)
outputFolder=C:/Documents/project/
echo "This is the start of the batch script"
#Run the R script and pass it arguments
Rscript C:/myRscript.R $outputFolder 10
ls $outputFolder
Note that the Rscript command in batch sometimes needs an R module to be loaded or you have to specify the full path to the Rscript (depending on the machine you're working on)
I hope this helps clarify the use of Rscript a bit!
PJ