在Visual Studio Code终端中打开CMD

vin*_*c4f 9 cmd visual-studio-code

每当我在Visual Studio Code中打开终端时,我都会得到一个bash shell.我想将CMD添加为第二个shell.为此,我查看了VS Code文档并找到了以下命令:

CTRL+ SHIFT+`

但它只打开第二个bash shell.是否有在集成终端中打开CMD的快捷方式,而不是在外部控制台中打开它?

Screengrab显示VSCode中的控制台窗口

小智 18

  1. Ctrl + Shift + P打开命令面板。
  2. 键入“外壳”的搜索。
  3. 选择“终端:选择默认外壳”
  4. 选择“命令提示符”
  5. 下次尝试打开终端时,您应该看到'CMD'而不是'PowerShell'

  • 这个选项在 vs code 1.59 中不再存在 (2认同)

Lle*_*wey 12

如果要始终打开cmd,可以使用设置进行配置.

来自文档:

在Windows上正确配置shell需要找到正确的可执行文件并更新设置.以下是常见shell可执行文件及其默认位置的列表:

 // 64-bit cmd if available, otherwise 32-bit
 "terminal.integrated.shell.windows": "C:\\Windows\\sysnative\\cmd.exe"
 // 64-bit PowerShell if available, otherwise 32-bit
 "terminal.integrated.shell.windows": "C:\\Windows\\sysnative\\WindowsPowerShell\\v1.0\\powershell.exe"
  // Git Bash
  "terminal.integrated.shell.windows": "C:\\Program Files\\Git\\bin\\bash.exe"
 // Bash on Ubuntu (on Windows)
 "terminal.integrated.shell.windows": "C:\\Windows\\sysnative\\bash.exe"
Run Code Online (Sandbox Code Playgroud)

如果您只想打开cmd,您可以简单地打开一个新的bash终端,然后cmd在其中运行.

如果你经常使用它们,你可能想要使用这样这样的扩展,它允许你在启动时选择你的终端.

键绑定:

  [{
    "key": "ctrl+shift+t",
    "command": "shellLauncher.launch"
  }]
Run Code Online (Sandbox Code Playgroud)

设置:

  {
    "shellLauncher.shells.windows": [
      {
        "shell": "bash",
        "args": [],
        "label": "bash"
      }, {
        "shell": "cmd",
        "args": [],
        "label": "cmd"
      }
    ]
  }
Run Code Online (Sandbox Code Playgroud)


小智 8

在用户设置上添加此 注意:粘贴在顶部

{

   "terminal.integrated.shell.windows": "cmd.exe"
    // other settings...

}
Run Code Online (Sandbox Code Playgroud)


Suy*_*ash 8

我不知道为什么其他人还没有提到它,但这是在 VSCode 中打开 CMD 的最简单方法。

只需在终端中输入 CMD 并按 Enter 键即可。


小智 5

您可以将当前终端更改为您需要(或拥有)的任何终端。

在此输入图像描述

或者您可以使用Ctrl + Shift + P打开命令面板并输入Terminal Profile,然后更改默认配置文件。

在此输入图像描述

在此输入图像描述

这将更改您的启动终端。如果您启动一个新终端,默认终端将始终打开。