通过任务计划程序运行批处理文件时,httpuv无法启动oauth服务器

时间:2018-08-18 12:18:29

标签: r windows batch-file taskscheduler r-googlesheets

我有一个启动R脚本的批处理文件:

"C:\Program Files\R\R-3.3.1\bin\x64\Rscript.exe" "C:\Folder\Script.R"

在此R脚本中,我使用gs_auth函数来获取我的身份验证令牌并在R会话中使用它。通过从Folder Explorer双击批处理文件,我可以成功运行R脚本,并且一切运行正常。

设置任务计划程序任务以运行批处理文件时,我收到以下错误:

Error in httpuv::startServer(use$host, use$port, list(call = listen)) :
  Failed to create server
Calls: gs_title ... init_oauth2.0 -> oauth_authorize -> oauth_listener -> <Anonymous>
Execution halted

我曾在Task Scheduler中尝试过“以最高特权运行”,还输入了Windows密码,但似乎无济于事。

在加载令牌方面我缺少什么东西吗?


代码

这里有注释掉的行,因为它们显示了“烘烤”令牌的初始化步骤,以便以后使用。按照here遵循这些步骤。

##Need to run gs_auth line only because need to paste stuff in from IE
#token <- gs_auth(cache = FALSE)
#gd_token()
##Bake token to working directory
#saveRDS(token, file = "googlesheets_token.rds")

setwd("C:/Folder")
gs_auth(token = "googlesheets_token.rds")

for_gs <- gs_title("data_log")
for_gs_sheet <- gs_read(for_gs)

XML:

<?xml version="1.0" encoding="UTF-16"?>
<Task version="1.4" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
  <RegistrationInfo>
    <Date>2018-08-18T15:11:51.0347984</Date>
    <Author>abc-PC\User</Author>
    <URI>\ozb</URI>
  </RegistrationInfo>
  <Principals>
    <Principal id="Author">
      <UserId>S-1-5-21-2866463773-2659414307-4023886308-1002</UserId>
      <LogonType>InteractiveToken</LogonType>
    </Principal>
  </Principals>
  <Settings>
    <DisallowStartIfOnBatteries>true</DisallowStartIfOnBatteries>
    <StopIfGoingOnBatteries>true</StopIfGoingOnBatteries>
    <Enabled>false</Enabled>
    <MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>
    <IdleSettings>
      <StopOnIdleEnd>true</StopOnIdleEnd>
      <RestartOnIdle>false</RestartOnIdle>
    </IdleSettings>
    <UseUnifiedSchedulingEngine>true</UseUnifiedSchedulingEngine>
  </Settings>
  <Triggers>
    <CalendarTrigger>
      <StartBoundary>2018-08-18T15:00:00</StartBoundary>
      <Repetition>
        <Interval>PT15M</Interval>
      </Repetition>
      <ScheduleByDay>
        <DaysInterval>1</DaysInterval>
      </ScheduleByDay>
    </CalendarTrigger>
  </Triggers>
  <Actions Context="Author">
    <Exec>
      <Command>"C:\Folder\run_it.bat"</Command>
    </Exec>
  </Actions>
</Task>

0 个答案:

没有答案