Created a simple project using Rstudio and included renv. It simply creates txt file in project directory.
created batch file:
CALL "C:\Program Files\R\R-4.3.2\bin\Rscript.exe" -e "renv::load('C:/Users/username/R/ProjectFolder'); source('C:/Users/username/R/Test1/Test1.R')"> "C:/Users/username/R/Test1/Output.log" 2>&1
exit
If I double click on batch file - works fine.
But if I use task scheduler to run batch file it gives me an error:
Error in loadNamespace(x) : there is no package called 'renv'
Calls: loadNamespace -> withRestarts -> withOneRestart -> doWithOneRestart
Execution halted
Seems like it does not activate renv.
Task scheduler snip:


.Rprofilefile (I believe) that sets up the environment so thatrenvis found. Do you have a way in task-scheduler to set the working directory to that proj dir?source("renv/activate.R")CD "C:\Users\username\R\ProjectFolder"(and then theCALL ...on the next line).