I have a scheduled task that is set to run an R script by launching Rscript.exe and the file of interest.
This task completes successfully when I run it with the option
"Run only when user is logged on".
I need to schedule the task to run without me, so I checked the option:
"Run whether user is logged on or not"
and gave it my password.
I needed to test this and thus clicked "run" only to watch it immediately fail with a result of
There is a log file created by R when the script runs, however the scheduled task apparently failed before this log was created.
I found this resource, which says that when the task cannot be successfully run manually when the "whether user is logged on or not" option is checked.
With that in mind I instead scheduled the task to run a few minutes in the future. The task again failed with the 0x1 run result before launching Rscript and thus creating a log.
I repeated this process and few times and the result was the same each time.
When I look at the task's properties I see that in 1 second of time it reached the "Action Completed" step which returned a non-zero return code and failed with an Operational Code of "(2)".
The task definition is:
Action: Start a program Program/script: cmd Add arguments: /c E:/PROGRA~1/R/R-33~1.1/bin/Rscript.exe T://code//Forecast.R >> T://code//Forecast.log 2>&1