且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在VsCode中在按键上执行bat文件

更新时间:2022-12-19 07:41:35

tasks.json 中,创建一个任务来运行 .bat .像这样:

In tasks.json, create a task to run the .bat. Something like this:

{
    "label": "build",
    "type": "shell",
    "command": "MY_BAT_FILE.bat",
    "presentation": {"echo": true, "reveal": "always", "focus": false, "panel": "shared", "showReuseMessage": false, "clear": true},
    "group": {"kind": "build", "isDefault": true},
},

然后,使用 Tasks:Run Build Task 热键(默认情况下为 Ctrl Shift B ).br>它将运行标有"isDefault":true 的任务.

Then, use the Tasks: Run Build Task hotkey (CtrlShiftB by default).
It will run the task marked with "isDefault": true.

如果您想要多个热键,则可以在 keybindings.json 中添加如下所示的条目:

If you want more than one hotkey, you can instead add entries like following to your keybindings.json:

{"key": "f5", "command": "workbench.action.tasks.runTask", "args": "build"},
//       ^~ shortcut                                                ^~~~~ task name