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

TylerH
  • 20,799
  • 66
  • 75
  • 101
Jaskeil
  • 1,044
  • 12
  • 33
  • Does this answer your question? [Why does my Task Scheduler task fail with error 2147942667?](https://stackoverflow.com/questions/13618945/why-does-my-task-scheduler-task-fail-with-error-2147942667) – TylerH Jun 08 '22 at 13:39
  • Note - the error above (2147842667) is what Windows Event Logs record for a Task that has a run result of (0x1). – TylerH Jun 08 '22 at 13:39

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
  • @Jaskeil "*directory name is invalid*" means Windows can't find or access the directory you have specified. My first guess is you used forward slashes when Windows file directory uses back slashes instead (e.g. it should be "C:\Users\santi\...", not "C:/Users/santi/...". Windows has no concept of something called "C:/". – TylerH Jun 08 '22 at 13:37