I\'ve been using Beta 2 for a while now and it\'s been driving me nuts that I have to punt to cmd.exe when running the VS2010 Command Prompt. I used to have a nice vsvars200
For someone who is still struggling with it in 2020 and Visual Studio Code 1.41.1, so a bit off topic here.
Using all different parts of code from above and the Internet e.g. from https://help.appveyor.com/discussions/questions/18777-how-to-use-vcvars64bat-from-powershell and with a step by step approach I managed to have the below script working.
Saved into VSCode "settings.json" and with the Code Runner extension installed.
With Microsoft (R) C/C++ Optimizing Compiler Version "cl.exe" from Visual Studio 2015/14.0:
"code-runner.runInTerminal": true,
"code-runner.executorMap": {
"cpp": "cd $dir; pushd \"C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\"; cmd.exe /c \"call vcvarsall.bat x86_amd64 & set > %temp%\\vcvars.txt\"; Get-Content \"$env:temp\\vcvars.txt\" | Foreach-Object { if ($_ -match \"^(.*?)=(.*)$\") { Set-Content \"env:\\$($matches[1])\" $matches[2] }}; popd; cls; cl *.cpp; .\\\"$fileNameWithoutExt.exe\"; Write-Host -NoNewLine 'Press any key to continue...'; $null = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown'); del \"$fileNameWithoutExt.exe\"; del \"$fileNameWithoutExt.obj\""}
With Microsoft (R) C/C++ Optimizing Compiler Version "cl.exe" from Visual Studio 2019/16.4.3:
"code-runner.runInTerminal": true,
"code-runner.executorMap": {
"cpp": "cd $dir; pushd \"c:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\VC\\Auxiliary\\Build\"; cmd.exe /c \"call vcvarsall.bat x86_amd64 & set > %temp%\\vcvars.txt\"; Get-Content \"$env:temp\\vcvars.txt\" | Foreach-Object { if ($_ -match \"^(.*?)=(.*)$\") { Set-Content \"env:\\$($matches[1])\" $matches[2] }}; popd; cls; cl *.cpp; .\\\"$fileNameWithoutExt.exe\"; Write-Host -NoNewLine 'Press any key to continue...'; $null = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown'); del \"$fileNameWithoutExt.exe\"; del \"$fileNameWithoutExt.obj\""}
HTH