Thomas Andersen
Thomas Andersen

Reputation: 1529

Why aren't my Visual Studio Code task executing?

I am struggling with getting my Visual Studios code task to work. The problem is that it seems like the task/.bat file is not being executed.

VS Code task configuration:

{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
        {
            "label": "My Label",
            "type": "shell",
            "windows": {
                "command": "'c:\\Program Files (x86)\\path\\to\\the\\file.bat${file}'"
            },
            "presentation": {
                "reveal": "always"
            },
            "group": {
                "kind": "build",
                "isDefault": true
            }
        }
    ]
}

For testing purposes the file.bat contains:

echo "------"
echo %1
echo "------"

The output in Visual Studio Code terminal is:

> Executing task in folder User: 'c:\\Program Files (x86)\\path\\to\\the\\file.bat c:\project\file.abc' <

c:\\Program Files (x86)\\path\\to\\the\\file.bat c:\project\file.abc

Terminal will be reused by tasks, press any key to close it.

I expected that the ${file} argument/value to printed in the console. The problem is that nothing is printed. It doesn't matter if I intentionally make syntax errors in the bat file. From VS Code it seems like the .bat file is not executed at all.

The shell being used is PowerShell

Configuration:

"terminal.integrated.shell.windows": "C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\powershell.exe"

Thank you in advance!

T

Upvotes: 1

Views: 1771

Answers (1)

Stewart_R
Stewart_R

Reputation: 14485

You just have a slight syntax error using double quotes and single quotes together.

Change to:

...

"windows": {
            "command": "c:\\Program Files (x86)\\path\\to\\the\\file.bat ${file}"
        }

...

Upvotes: 1

Related Questions