【问题标题】:Error when trying to load Powershell script?尝试加载 Powershell 脚本时出错?
【发布时间】:2020-02-26 20:46:38
【问题描述】:

我想在任务中调用我的 Powershell 脚本,但每当我尝试运行该脚本时,我都会继续收到此错误;

终端外壳 CWD "\Custom Program Settings\Projects.Code" 确实 不存在

终端将被任务重用,按任意键关闭它。

脚本通过./.tasks/pathExtend.ps1 调用它曾经工作过一次,使用另一个脚本,相同的路径;自从更改脚本以来;错误返回?

【问题讨论】:

  • 所以修改脚本后就不行了。什么脚本?
  • 从 VS Code 打开你的“tasks.json”。在此处复制并粘贴内容。
  • 堆栈溢出是否限制了我的字符数?

标签: powershell visual-studio-code


【解决方案1】:

如果你是从另一个脚本调用脚本,那么你可以试试这个:

Start-Process -Wait powershell.exe -Verb RunAs -ArgumentList ('-noprofile -file c:\script\myscript.ps1 -elevated' -f ($myinvocation.MyCommand.Definition))

【讨论】:

  • 我不是从另一个脚本调用脚本,我想让任务调用脚本,脚本从那里调用命令。
【解决方案2】:

我认为您的“./.tasks/pathExtend.ps1”路径是错误的。尝试 ././tasks/pathExtend.ps1、../tasks/pathExtend.ps1 或 ./tasks/pathExtend.ps1

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-08-04
    • 1970-01-01
    • 1970-01-01
    • 2014-01-30
    • 1970-01-01
    • 2016-08-29
    • 1970-01-01
    • 2013-02-23
    相关资源
    最近更新 更多