10

This trick seems very simple but I don't know how to set up,
What I did :
Go to Archive > Preferences > User Config.
and in the right panel I wrote this...

{
    "terminal.integrated.shell.windows": 
    "C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Community\\Common7\\Tools\\VsDevCmd.bat"
}

works until suddenly disappears.
Thinking about a launch.json script just for the sake of not writing on the console and using a play button, I know cl is for calling the compiler but don't know how to deal with the parameters. Someone suggested to use Cmake.
All I want is to run scratch code with the VC/C++ compiler (not limited to the 2017 version, could be any) so any solution will be highly appreciated.

1
  • I want to compile my C/C++ program in the VS Dev Cmd Prompt. Please help someone...
    – broodjetom
    Apr 28, 2017 at 21:00

5 Answers 5

4

Just updating the @K0j0 answer :)

Here is for Microsoft Visual Studio 2017 Community.

{
    // New shell with Developer Command Prompt
    "terminal.integrated.shell.windows": "C:\\Windows\\Sysnative\\cmd.exe",
    "terminal.integrated.shellArgs.windows": ["/k", "C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Community\\Common7\\Tools\\VsDevCmd.bat"]
}
3

Try this

{

"terminal.integrated.shell.windows": "C:\\Windows\\Sysnative\\cmd.exe",
"terminal.integrated.shellArgs.windows": ["/k", "C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\Common7\\Tools\\VsDevCmd.bat"]
}

Seems like you you need to use cmd as the shell but pass in /k and the batch script that sets the proper environment variables for the dev command prompt.

Btw, my command prompt is for Visual Studio 2015, you'll want to update yours for your version which looks like 2017.

1
  • This didn't work but forward slashes instead of double back slashes for the shellArgs.windows line works for me.
    – bitrock
    Jul 7, 2020 at 3:25
3

While the other answers are still valid, note that the current (Nov. 2021) way of doing this is to use the terminal-profiles; the other mentioned methods have been deprecated.

    "terminal.integrated.profiles.windows": {
        "Command Prompt": {
            "path": [
                "${env:windir}\\Sysnative\\cmd.exe",
                "${env:windir}\\System32\\cmd.exe"
            ],
            "args": [
                "/K",
                "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\Common7\\Tools\\VsDevCmd.bat",
            ],
            "icon": "terminal-cmd"
        }
    }
2

Luiz's response mentions the 32bit command prompt. The following are the settings for the 64bit Visual Studio 2017 Developer command prompt:

   "terminal.integrated.shell.windows": "C:\\Windows\\Sysnative\\cmd.exe",
    "terminal.integrated.shellArgs.windows": [
        "/k",
        "C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Community\\VC\\Auxiliary\\Build\\vcvars64.bat"
    ],
2

VS Code 1.73.1 and Visual Studio 2022 Developer Command Prompt v17.4.1 as of Nov 2022

go to with Windows Run to edit VS Code setting json

%APPDATA%\Code\User\settings.json

Add this inside { } of "terminal.integrated.profiles.windows"

"Developer Powershell": {
      "path": [
        "${env:windir}\\Sysnative\\cmd.exe",
        "${env:windir}\\System32\\cmd.exe"
      ],
      "args": [
        "/k",
        "C:\\Program Files\\Microsoft Visual Studio\\2022\\Professional\\Common7\\Tools\\VsDevCmd.bat"
      ],
      "icon": "terminal-powershell"
    }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.