在Visual Studio Code终端中打开CMD

时间:2017-09-08 02:57:51

标签: cmd visual-studio-code

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

CTRL + SHIFT + `

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

Screengrab showing console window in VSCode

5 个答案:

答案 0 :(得分:11)

如果您想要始终打开cmd,可以使用这些设置进行配置。

来自docs

  

在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"

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

如果您经常使用这两种扩展程序,则可能需要使用thisthis这样的扩展程序,以便在启动终端时选择终端。

键绑定:

  [{
    "key": "ctrl+shift+t",
    "command": "shellLauncher.launch"
  }]

设定:

  {
    "shellLauncher.shells.windows": [
      {
        "shell": "bash",
        "args": [],
        "label": "bash"
      }, {
        "shell": "cmd",
        "args": [],
        "label": "cmd"
      }
    ]
  }

答案 1 :(得分:8)

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

答案 2 :(得分:2)

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

{

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

}

答案 3 :(得分:1)

只需打开终端并输入指向您的cmd应用程序的链接,例如 C:\ Windows \ system32 \ cmd.exe

答案 4 :(得分:0)

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

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