在r system2()

问题描述 投票:0回答:1
system2("powershell", args=c("-File", "C:\\PathToFile\\PowerShellScript.ps1"))

powershell脚本本身非常简单。它应该启动PowerPoint(出于演示目的)。

Start-Process "powerpnt.exe"

但是,执行失败的失败以下错误输出(我将其翻译成英语,因此希望内容正确给出...)

Error处理文件“ C:\ Pathtofile”,因为该文件
没有扩展名为“ .ps1”。输入Gwindows Powershell
版权(C)Microsoft Corporation。保留所有权利
安装最新的powershell

一些注释:

,您可以看到我的文件具有扩展名

.ps1

我的PowerShell版本是5.1.22621.4391

我还试图设置一个更好的拟合executionPolicy,但是在PowerShell中,另一个executionPolicy

unrestructiond with with
  • 因此,您能帮我执行我的PowerShell脚本吗?非常感谢
  • 所述的行为与您通过包含Whitespace的不合格的文件路径的情况一致,即:
  • powershell -File C:\Path with spaces\to\file.ps1 解决此问题的方法是用字面的引号符合道路的全部范围:
powershell -File "C:\Path with spaces\to\file.ps1"

在r字符串中,您应该能够用简单的逃生序列
r powershell
1个回答
0
投票

表达

system2("powershell", args=c("-File", "\"C:\\PathToFile\\PowerShellScript.ps1\""))
    

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.