0

当我运行以下 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 在脚本上的位置,工作流似乎也在尝试访问 RScript.exe 的网络中我的用户的本地路径Start-LocalRScript。有谁知道这里发生了什么?

4

1 回答 1

0

而不是调用运算符 ( &) 使用Start-Process设置-WorkingDirectory为正确的工作目录。

于 2017-10-05T17:43:05.867 回答