1

I'm trying to start an external program through VSCode (this program connects an LAN device and prints on the console information received on a specific port). I've searched all the forums but can't find a working solution.

I've tried creating a launch task in 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"            
        }
    ]
}

While this start the program in an external window I se the following error

enter image description here

(However if I run the program via a shortcut from the desktop it works fine)

Then I tried creating a Build task in 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": []
        }
    ]
}

While this runs the program and shows the logging output, it always opens the program in the integrated terminal and never in a new window when I run the task

Then I tried using a modified version as someone suggested I change the task command to:

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

and it throws this error (again from the integrated terminal) when I run the task (still doesn't open an external terminal 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

Any suggestions?

rboy
  • 2,018
  • 1
  • 23
  • 35

1 Answers1

1

Okay I finally figured it out and I've posted the solution over here with all the necessary details and samples

https://stackoverflow.com/a/70988694/2280961

rboy
  • 2,018
  • 1
  • 23
  • 35