1

I am currently looking at this documentation to automate a script on my machine using R and taskscheduleR. I am confused within this documentation of the following:

In the example within the documentation, what is "extdata", is this supposed to be the file path of my R script and is "helloworld.R" the actual R script?

myscript <- system.file("extdata", "helloworld.R", package = "taskscheduleR")

My current take at this is below: Where C:/Users/santi/Documents/R Scripts is my file path and Wayerhaeuser_Automation_script.R is my actual R script

myscript <- system.file("C:/Users/santi/Documents/R Scripts", "Wayerhaeuser_Automation_script.R", package = "taskscheduleR")

taskscheduler_create(taskname = "myfancyscript", rscript = myscript, 
                     schedule = "ONCE", starttime = format(Sys.time() + 62, "%H:%M"))

I was a bit confused on the documentation of it.

Attempt after trying proposed solution: enter image description here

Jaskeil
  • 778
  • 5
  • 18

1 Answers1

0

Change myscript to:

myscript <- paste0("C:/Users/santi/Documents/R Scripts/","Wayerhaeuser_Automation_script.R")

and it should work just fine. The rscript argument is just a string path to the file to run. Sometimes paths are interpreted improperly if there are spaces, so if it doesn't work, also try changing the folder name to R_Scripts

  • Thanks I did this and the script did not run. Within my task schedulder Last Run Result column I geta message of `0x1` I am unsure what that means. I will update the question with a screenshot – Jaskeil Jun 02 '21 at 16:40
  • This may help you out, it can be something to do with permissions on Windows https://stackoverflow.com/questions/18370547/windows-scheduled-task-succeeds-but-returns-result-0x1 –  Jun 02 '21 at 16:48
  • Thanks, I have followed the directions and I am now getting a `directory name is invalid` error. If I am understanding correctly do I need to explicity type Program/Script in the Start in (optional): area? – Jaskeil Jun 02 '21 at 17:00