【问题标题】:Visual Studio Code tasks.json issue with path in powershellPowerShell中路径的Visual Studio Code tasks.json问题
【发布时间】:2019-06-19 12:42:35
【问题描述】:

我有一个插件,每次点击保存时都会运行一个命令。 当我尝试在保存时运行批处理文件时出现以下错误:

命令 autopush.bat 未找到,但当前确实存在 地点。 Windows PowerShell 不从当前加载命令 默认位置。如果您信任此命令,请键入: “.\autopush.bat”。有关更多信息,请参阅“get-help about_Command_Precedence” 详情。

我的 settings.json 文件:

{
    "saveAndRun": {
        "commands": [
          {
            "match": ".*",
            "cmd": "autopush.bat",
            "useShortcut": false,
            "silent": false
          }
        ]
      }
} 

我不确定如何在“autostart.bat”中添加点和反斜杠

我尝试使用“.\b autostart.bat”,但没有成功。

【问题讨论】:

    标签: json powershell batch-file visual-studio-code


    【解决方案1】:

    我的错,我使用了错误的转义字符。我必须使用.\\autostart.bat,如下所述:How to escape special characters in building a JSON string?

    \b  Backspace (ascii code 08)
    \f  Form feed (ascii code 0C)
    \n  New line
    \r  Carriage return
    \t  Tab
    \"  Double quote
    \\  Backslash character
    

    【讨论】:

      猜你喜欢
      • 2021-11-01
      • 2022-12-16
      • 2021-11-17
      • 2021-02-11
      • 1970-01-01
      • 2020-06-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多