Visual Studio 代码 (Windows 10) 通过 launch 或 tasks 启动外部程序

Visual Studio Code (Windows 10) start external program via launch or tasks

我正在尝试通过 VSCode 启动外部程序(该程序连接 LAN 设备并在控制台上打印在特定端口上接收到的信息)。我搜索了所有论坛,但找不到有效的解决方案。

我尝试在 launch.json

中创建启动任务
{
    "configurations": [
        {
            "name": "Start Logging Console",
            "type": "node",
            "request": "launch",
            "program": "D:\My Drivers\things.exe",
            "args" : [
               "log", "--all", "--address=192.168.1.8"
            ],
            "cwd": "${workspaceFolder}",
            "console": "externalTerminal"            
        }
    ]
}

虽然这在外部启动程序 window 我看到以下错误

(但是,如果我 运行 通过桌面快捷方式运行该程序,它可以正常工作)

然后我尝试在 tasks.json

中创建一个构建任务
{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "Start logging console",
            "type": "shell",
            "command": "${workspaceFolder}\things.exe",
            "args": [
                "log",
                "--all",
                "--hub-address=192.168.1.8"
            ],
            "options": {
                "cwd": "${workspaceFolder}"
            },
            "presentation": {
                "reveal": "always",
                "panel": "new",
            },
            "problemMatcher": []
        }
    ]
}

虽然这个 运行 是程序并显示日志输出,但它总是在集成终端中打开程序,而当我 运行 任务[时,它永远不会在新的 window 中打开程序

然后我尝试使用修改后的版本,因为有人建议我将任务 command 更改为:

"command": "Start-Process -FilePath \"${workspaceFolder}\things.exe\"",

当我 运行 任务(仍然没有打开外部终端 window)

时,它会抛出这个错误(再次从集成终端)
& : The term 'Start-Process -FilePath D:\Drivers\things.exe' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, 
or if a path was included, verify that the path is correct and try again.
At line:1 char:3
+ & 'Start-Process -FilePath D:\...
+   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Start-Process -...things.exe:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

有什么建议吗?

好吧,我终于弄明白了,我已经在此处发布了解决方案,其中包含所有必要的详细信息和示例