I have a Visual Studio Code task that executes a batch script using the following code:
{
"version": "2.0.0",
"tasks": [
{
"label": "Run batch file",
"type": "shell",
"windows": {
"command": "${workspaceFolder}\\run_script.bat",
"args": [
"arg1",
"arg2"
]
},
"presentation": {
"focus": true,
"clear": true,
"panel": "shared"
}
}
]
}
When I run the task, a new console is opened, output appears for a brief second, and then the console closes.
How to redirect the output to visual studio code's integrated terminal without opening any extra consoles?
UPDATE 1
Here's my vs code settings.json:
{
"http.proxy": "[A URL I REMOVED ONLY FOR THIS POST]",
"window.zoomLevel": 1,
"files.autoSave": "afterDelay",
"explorer.confirmDelete": false,
"git.enableSmartCommit": true,
"git.confirmSync": false,
"workbench.startupEditor": "none",
"diffEditor.ignoreTrimWhitespace": false,
"editor.accessibilitySupport": "off",
"git.ignoreRebaseWarning": true,
"autopep8.args": [
"--ignore=E501"
],
"diffEditor.renderSideBySide": false
}
UPDATE 2
I was experimenting and other batch files outputs are shown in the integrated terminal. Even output of echo commands in the 'run_script.bat' file. So the problem is particular to one specific line in my batch file:
start /w "" "%path_to_exe%" /arg1 /arg2
I think this is the line opening a separate console and outputting there. How do I redirect its output to vs code's integrated terminal?
Thanks.
As I wrote in my update, the issue had nothing to do with how the task was configured. It was with the line
start /w "" "%path_to_exe%" /arg1 /arg2of my batch script.After reading the documentation of the
startcommand, I added the /B option.The line was now:
and the output was automatically redirected to VS Code's integrated terminal.