【问题标题】:UNC error on a powershell workflowPowerShell 工作流上的 UNC 错误
【发布时间】:2017-10-04 11:20:09
【问题描述】:

当我运行以下 powershell 工作流程时:

Function Start-LocalRScript {
  Param([Parameter(ValueFromPipeline, Mandatory)]$Name)
  $ScriptPath = "C:\Exploration.RScripts"
  $RScriptExePath = "C:\Program Files\R\R-3.1.2\bin\Rscript.exe"
  $scriptPath = Join-Path -Path $ScriptPath -ChildPath $Name
  & $RScriptExePath $scriptPath
}

Workflow Get-RScriptWorkflow {
  Start-LocalRScript script1.R
}

我得到以下错误,但我仍然得到 R 脚本的结果:

Rscript.exe : '\\srvuser01\profil\myUser\Documents' At Get-RScriptWorkflow:2 char:2
+ CategoryInfo          : NotSpecified ('\\srvuser01\profil\myUser\Documents':String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
+ PSComputerName        : [localhost] 
CMD.EXE was started with the above path as the current directory.
UNC paths are not supported.  Defaulting to Windows directory.  
[1] "from script 1"

但是当我运行命令Start-LocalRScript script1.R 时没有错误。即使我指定了 RScript.exe 在脚本Start-LocalRScript 上的位置,工作流似乎也在尝试访问 RScript.exe 的网络中我的用户的本地路径。有谁知道这里发生了什么?

【问题讨论】:

    标签: rscript powershell-workflow


    【解决方案1】:

    代替呼叫操作员 (&) 使用 Start-Process 并将 -WorkingDirectory 设置为正确的工作目录。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-10-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-09-15
      相关资源
      最近更新 更多