【问题标题】:can't using Start-Process powershell.exe run a ps1 file at onedrive path无法使用 Start-Process powershell.exe 在 onedrive 路径运行 ps1 文件
【发布时间】:2020-01-13 03:36:54
【问题描述】:

我在 Onedrive for Business 路径中有一个 ps1 文件。在命令下运行时,它出错了,但运行速度如此之快,我无法获得错误截图。 如果我将脚本放在另一个本地驱动器路径中,它可以正常工作。 Onedrive 中有什么预防措施?

Start-Process powershell.exe -ArgumentList $ps1path

ps文件内容

$current_path = Split-Path -Parent $MyInvocation.MyCommand.Definition
$up1_path = Split-Path -Parent $current_path
$up2_path = Split-Path -Parent $up1_path
$up1_path
$up2_path

cmd /c "pause"

【问题讨论】:

  • 当您在powershell中运行命令时,执行后powershell窗口是否关闭?什么跑得这么快?
  • 我不知道它运行的是哪个脚本。我在脚本末尾暂停了。
  • 我试过 Set-ExecutionPolicy -ExecutionPolicy bypass ,还是不行。

标签: powershell onedrive


【解决方案1】:

这不是 Onedrive 机箱。只是启动进程不能接受 ArgumentList 中的空格。

$pspath = $pspath -replace ' ','` '
Start-Process powershell.exe -ArgumentList $pspath

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-04-28
    • 1970-01-01
    • 1970-01-01
    • 2019-01-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多