vbscript - Running a .vbs script through R, scheduled in Task Scheduler -


i have vbs script takes excel file , saves pdf. call vbs within rscript automated through task scheduler. rscript runs fine when run in r manually. however, when have scheduled in task scheduler, task says completes successfully, pdf file not saved. different task scheduler running rscript cause not complete?

here rscript, have saved hourlyr.r in same c:\test folder.

shell.exec("c:/test/hourlynew.vbs") 

here code hourlynew.vbs

option explicit  excelmacro  sub excelmacro()    dim xlapp   dim xlbook   dim xlsheet    set xlapp = createobject("excel.application")   set xlbook = xlapp.workbooks.open("c:\\test\\hourly.xlsm", 0, false)   set xlsheet = xlbook.worksheets("hourlydashboard")    xlapp.displayalerts = false   xlapp.visible = false     xlsheet.exportasfixedformat 0, "c:\\test\\hourlydashboard.pdf", 0, 1, 0, , , 0   xlbook.close   xlapp.quit    set xlbook = nothing   set xlapp = nothing  end sub 

here how have scheduled task set up:

general tab:
run whether user logged in or not selected
run highest privileges checked

actions tab:
program/script: c:\r_program_files\r-3.2.0\bin\x64\r.exe
add arguments (optional): cmd batch c:\test\hourlyr.r

the problem in excel, best bet debugging step step. first, specify working directory in task's "start in" option. run task, navigate directory , check if .rout file created when task executed. can contain errors , messages. if r doesn't generate errors, remove

xlapp.displayalerts = false xlapp.visible = false xlbook.close xlapp.quit 

run task again, , check whether new excel.exe process appears in task manager. if so, switch on "run when user logged on" option in task settings, way should see excel ui , messages displays.


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -