Closed BryanTegomoh closed 1 year ago
Consider using the full path to the xlsx file or consider switching the directory where you create the excel file or switching the user which executes the task. That will solve your problem.
Thank you. I tried a different user but it reproduced the error. I attempted to write the file path in full but still had the same error
In file.create(to[okay]) :
cannot create file 'Preprints by Sorted by Engagement from June-18 to July-02 2023 at 2156h.xlsx', reason 'Permission denied'
What was the taskscheduler code which you used to run the script under a different user. Which code did you use for the full path?
Script runs fine normally, however when added as a scheduled task, fails to complete
Warning message: In file.create(to[okay]) : cannot create file 'Top Preprints Feb-28 to Mar-14-2023 11 26.xlsx', reason 'Permission denied'
Code used:
` file_name <- paste0("Top Preprints ", format(Sys.Date()-14, "%b-%d"), " to ", format(Sys.time(), "%b-%d-%Y %H %M"), ".xlsx")
log_file <- "C:\Users\name\OneDrive\Desktop\Scheduled-Tasks\Rapid-Reviews-Infectious-Diseases-Script.log"
cat("Exporting output results (Generating attachment files)... \n\n")
export(top_combined_preprints, file_name, na.string = "Not available")`