user310291
user310291

Reputation: 38180

Why can't I see any output when executing a windows batch file with VS code tasks

I'm trying VS code tasks for the first time, I have created a test.bat file with

echo hello 

and this tasks.json

{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
        {
            "label": "test",
            "type": "shell",
            "command": "cmd /c c:\\test\\test.bat"
        }
    ]
}

When running the task, It seems to execute it but why can't I see any output from echo (ie "hello") ?

enter image description here

Upvotes: 2

Views: 2597

Answers (1)

idleberg
idleberg

Reputation: 12882

Arguments aren't supposed to be posted in command, so you're task should look like this:

{
  "command": "cmd",
  "args": ["/c", "c:\\test\\test.bat]
}

However, since Microsoft added auto-detection, the following should work as well:

{
  "type": "shell",
  "command": ""c:\\test\\test.bat"
}

See the custom task documentation for details.

Upvotes: 3

Related Questions