在Visual Studio Code终端中打开CMD

27
每当我在 Visual Studio Code 中打开终端时,我会得到一个 Bash shell。我想添加 CMD 作为第二个 shell。为了做到这一点,我浏览了 VS Code 文档,并找到了这个命令: CTRL+SHIFT+` 但它只会打开第二个 Bash shell。是否有快捷键可以在集成的终端中打开 CMD,而不是在外部控制台中打开呢? Screengrab showing console window in VSCode

也许这个链接能帮到你。 - Victor S.
8个回答

29
  1. Ctrl + Shift + P打开命令面板。
  2. 在搜索框中输入'profile'
  3. 选择'Terminal: Select Default Profile'
  4. 选择'Command Prompt'
  5. 下一次尝试打开终端时,您应该会看到'CMD'而不是'PowerShell'

5
在 VS Code 1.59 中,此选项已不再存在。 - Andy N

15

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

根据文档

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

// Command Prompt
"terminal.integrated.shell.windows": "C:\\Windows\\System32\\cmd.exe"
// PowerShell
"terminal.integrated.shell.windows": "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe"
// Git Bash
"terminal.integrated.shell.windows": "C:\\Program Files\\Git\\git-cmd.exe",
"terminal.integrated.shellArgs.windows": [
  "--command=usr/bin/bash.exe",
  "-l",
  "-i"
]
// Bash on Ubuntu (on Windows)
"terminal.integrated.shell.windows": "C:\\Windows\\System32\\bash.exe"
如果你只想偶尔打开cmd,你可以尝试打开一个新的bash终端,然后在其中运行cmd。 如果你经常使用两者,你可能希望使用像这个这个这样的扩展,允许你在启动终端时选择要使用的终端。 按键映射:
  [{
    "key": "ctrl+shift+t",
    "command": "shellLauncher.launch"
  }]

设置:

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

当我将这段代码放入设置JSON文件中时,会显示“未知配置设置”消息。 - Eng_Farghly

8

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

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


8

在用户设置中添加以下内容注意:粘贴在顶部

{

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

}

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

enter image description here

你可以使用 Ctrl + Shift + P 打开命令面板,然后输入终端配置文件,然后更改默认配置文件。

enter image description here

enter image description here

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

这个答案与区分硬盘驱动器字母的方法是一致的。 - vintprox

3

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


1

从VSCode打开cmd终端

Ctrl + Shift + C


0
如果您想要打开另一个CMD终端,可以从VS Code终端或任何其他终端使用以下命令:
@start run cmd . 

或者当你想要进入上一级目录并在那里打开命令提示符时:

cd .. & @start cmd .

打开 VS Code 终端, ~ + SHIFT + CTRL - Maxenn

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接