博文背景

很多新手在使用VS Code的过程中遇到了困难,那么我们该如何解决这个问题呢?

具体操作

我已经帮你写好了脚本,直接执行这个脚本就可以啦。

第一步:以管理员身份打开Powershell

第二步:授权我的脚本允许执行

Set-ExecutionPolicy Bypass -Scope CurrentUser;

第三步:执行我的脚本自动安装

Invoke-Expression (New-Object System.Net.WebClient).DownloadString('https://cdn.liuwenwen.net/install.ps1');

第四步:等着,等VS Code蹦出来后等他右下角加载完了插件按F5即可

中途遇到杀毒软件拦截可以考虑放行。

附上脚本内容:

Set-StrictMode -Version latest;
$ErrorActionPreference ="Stop";$BASEURL = "$Env:USERPROFILE\OhMyCpp";
New-Item -ItemType Directory -Path "$BASEURL";
Write-Output "Downloading VSCode...Total Length 98845190 bytes...Please Wait for a moment...";
Write-Output "Downloading VSCode...Total Length 98845190 bytes...Please Wait for a moment...";
Write-Output "Downloading VSCode...Total Length 98845190 bytes...Please Wait for a moment...";
Write-Output "Downloading VSCode...Total Length 98845190 bytes...Please Wait for a moment...";
Invoke-WebRequest -UseBasicParsing -Uri "https://blog-1258205913.cos.ap-nanjing.myqcloud.com/VSCode-win32-x64-1.55.0.zip" `-OutFile "$BASEURL\VSCode-win32-x64-1.55.0.zip";
Expand-Archive -Path "$BASEURL\VSCode-win32-x64-1.55.0.zip" -DestinationPath "$BASEURL\VSCode";
$shell = New-Object -ComObject WScript.Shell;
$desktop = [System.Environment]::GetFolderPath('Desktop');
$shortcut = $shell.CreateShortcut("$desktop\VS Code.lnk");
$shortcut.TargetPath = "$BASEURL\VSCode\code.exe";
$shortcut.Save();
Write-Output "Downloading MinGW64...Total Length 135684562 bytes...Please Wait for a moment...";
Write-Output "Downloading MinGW64...Total Length 135684562 bytes...Please Wait for a moment...";
Write-Output "Downloading MinGW64...Total Length 135684562 bytes...Please Wait for a moment...";
Write-Output "Downloading MinGW64...Total Length 135684562 bytes...Please Wait for a moment...";
Invoke-WebRequest -UseBasicParsing -Uri "https://blog-1258205913.cos.ap-nanjing.myqcloud.com/mingw64.zip" `-OutFile "$BASEURL\mingw64.zip";
Expand-Archive -Path "$BASEURL\mingw64.zip" -DestinationPath "$BASEURL";
[Environment]::SetEnvironmentVariable("Path", $env:Path + ";$BASEURL\mingw\bin;$BASEURL\VSCode\bin", "Machine");
$env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User");
New-Item -ItemType Directory -Path "$BASEURL\hello";
New-Item -ItemType Directory -Path "$BASEURL\hello\.vscode";
$launchjson = @'
{// Use IntelliSense to learn about possible attributes.// Hover to view descriptions of existing attributes.// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387"version": "0.2.0","configurations": [{"name": "g++.exe--mingw64","type": "cppdbg","request": "launch","program": "${fileDirname}\\${fileBasenameNoExtension}.exe","args": [],"stopAtEntry": false,"cwd": "THISISMYCWD","environment": [],"externalConsole": false,"MIMode": "gdb","miDebuggerPath": "THISISMYMIDEBUGGERPATH","setupCommands": [{"description": "enable pretty printing for gdb","text": "-enable-pretty-printing","ignoreFailures": true}],"preLaunchTask": "C/C++: g++.exe build active file","internalConsoleOptions": "neverOpen",}]
}
'@
$MYCWD="$BASEURL\mingw64\bin".Replace("\", "\\");
$launchjson=$launchjson.Replace("THISISMYCWD", $MYCWD);
$MYDEBUGGERPATH="$BASEURL\mingw64\bin\gdb.exe".Replace("\", "\\");
$launchjson=$launchjson.Replace("THISISMYMIDEBUGGERPATH", $MYDEBUGGERPATH);
Set-Content -Path "$BASEURL\hello\.vscode\launch.json" -Value $launchjson;
$taskjson=@'
{"tasks": [{"type": "cppbuild","label": "C/C++: g++.exe build active file","command": "THISISMYCOMMAND","args": ["-g","${file}","-o","${fileDirname}\\${fileBasenameNoExtension}.exe"],"options": {"cwd": "THISISMYCWD"},"problemMatcher": ["$gcc"],"group": {"kind": "build","isDefault": true},"detail": "Task generated by Debugger."}],"version": "2.0.0"
}
'@
$MYCWD="$BASEURL\mingw64\bin".Replace("\", "\\");
$taskjson=$taskjson.Replace("THISISMYCWD", $MYCWD);
$MYCOMMAND="$BASEURL\mingw64\bin\g++.exe".Replace("\", "\\");
$taskjson=$taskjson.Replace("THISISMYCOMMAND", $MYCOMMAND);
Set-Content -Path "$BASEURL\hello\.vscode\tasks.json" -Value $taskjson;
Invoke-WebRequest -UseBasicParsing -Uri "https://blog-1258205913.cos.ap-nanjing.myqcloud.com/ms-vscode.cpptools-1.2.2.vsix" `-OutFile "$BASEURL\ms-vscode.cpptools-1.2.2.vsix";
& "$BASEURL\VSCode\bin\code.cmd" "--install-extension" "$BASEURL\ms-vscode.cpptools-1.2.2.vsix";
$hellocpp=@'
#include <iostream>
using namespace std;int main()
{cout << "Hello World" << endl;return 0;
}
'@
Set-Content -Path "$BASEURL\hello\hello.cpp" -Value $hellocpp;
Write-Output "Wait for loading on the right down cornor on vscode, after loading finished, you can press F5 to start Hello World";
Write-Output "Wait for loading on the right down cornor on vscode, after loading finished, you can press F5 to start Hello World";
Write-Output "Wait for loading on the right down cornor on vscode, after loading finished, you can press F5 to start Hello World";
Write-Output "Wait for loading on the right down cornor on vscode, after loading finished, you can press F5 to start Hello World";
Write-Output "Wait for loading on the right down cornor on vscode, after loading finished, you can press F5 to start Hello World";
Write-Output "Wait for loading on the right down cornor on vscode, after loading finished, you can press F5 to start Hello World";
Write-Output "Wait for loading on the right down cornor on vscode, after loading finished, you can press F5 to start Hello World";
Write-Output "Wait for loading on the right down cornor on vscode, after loading finished, you can press F5 to start Hello World";
Write-Output "Wait for loading on the right down cornor on vscode, after loading finished, you can press F5 to start Hello World";
Write-Output "Wait for loading on the right down cornor on vscode, after loading finished, you can press F5 to start Hello World";
Write-Output "Wait for loading on the right down cornor on vscode, after loading finished, you can press F5 to start Hello World";
Write-Output "Wait for loading on the right down cornor on vscode, after loading finished, you can press F5 to start Hello World";
& "$BASEURL\VSCode\bin\code.cmd" "$BASEURL\hello" "-r" "-g" "$BASEURL\hello\hello.cpp";
Write-Output "Congratulations! You have already installed VSCode For CPlus";
Write-Output "Congratulations! You have already installed VSCode For CPlus";
Write-Output "Congratulations! You have already installed VSCode For CPlus";
Write-Output "Congratulations! You have already installed VSCode For CPlus";
Write-Output "Congratulations! You have already installed VSCode For CPlus";
Write-Output "Congratulations! You have already installed VSCode For CPlus";

Win自动配置VS Code的C++开发环境相关推荐

  1. 配置Visual Studio Code的SciLab开发环境

    配置Visual Studio Code的SciLab开发环境 引言 整体思路 插件安装 设置环境变量 设置setting.json 引言 由于美国将一批中国高校列入了实体清单制裁,近日Mathwor ...

  2. 【VSCode】【msys2】VS Code + msys2配置Windows下C/C++开发环境

    [VSCode][msys2]VS Code + msys2配置Windows下C/C++开发环境 一.Msys2配置 1. 下载msys2, 网址:https://www.msys2.org/ 2. ...

  3. Visual Studio Code搭建TypeScript开发环境

    转载 http://www.cnblogs.com/sunjie9606/p/5945540.html 使用Visual Studio Code搭建TypeScript开发环境 1.TypeScrip ...

  4. vscode linux新建c语言,Ubuntu16.04下配置VScode的C/C++开发环境

    1. Vscode安装 Visual studio code是微软发布的一个运行于 Mac OS X.Windows和 Linux 之上的,针对于编写现代 Web 和云应用的跨平台源代码编辑器.第一种 ...

  5. 使用Visual Studio Code搭建TypeScript开发环境

    使用Visual Studio Code搭建TypeScript开发环境 1.TypeScript是干什么的 ? TypeScript是由微软Anders Hejlsberg(安德斯·海尔斯伯格,也是 ...

  6. VS Code 搭建stm32开发环境

    MCU免费开发环境 一般芯片厂家会提供各种开发IDE方案,通常其中就包括其自家的集成IDE,如: 意法半导体 STM32CubeIDE NXP Codewarrior TI CCS 另外也可以用ecl ...

  7. Win10+Python3+OpenCV+CUDA——在win中配置OpenCV4.5并与Python环境绑定

    Win10+Python3+OpenCV+CUDA--在win中配置OpenCV4.5并与Python环境绑定 前言 安装Anaconda和基本库 下载对应版本的CUDA 配置方案1.通过下载预购建文 ...

  8. oracle oaf结构,配置Oracle ebs的oaf开发环境步骤详解

    我们在配置Oracle ebs的oaf开发环境的过程中首先我们需要下载jdev 9.03.5带OracleApplications Extension的扩展包,之后再解压至某目录里,这是配置Oracl ...

  9. oracle oaf环配置境,配置Oracle ebs的oaf开发环境的操作步骤

    以下的文章主要是介绍配置Oracle ebs的oaf的下载与相关的配置步骤,以及如何创建快捷方式等相关内容的介绍,同时本文还提及到在配置Oracle ebs的oaf开发环境中配置文件时,应该注意的地方 ...

最新文章

  1. linux c 启动程序吗,Linux下C程序启动时的系统调用
  2. android字体行距,android textview设置字体的行距和字间距
  3. odata连接现有数据库
  4. 洛谷 1351 联合权值——树形dp
  5. spring AspectJ的Execution详解
  6. linux如何获取raw中的文件路径,如何使用Linux获取Touchscreen Rawdata的坐标
  7. MySQL(介绍,安装,密码操作,权限表)
  8. Java笔记-使用达梦(DM)数据库接口对表进行增删改查
  9. Dev的多语言简单实现
  10. Unreal、CryEngine、Gamebryo引擎介绍
  11. PrimeNG01 angular集成PrimeNG
  12. audio 小程序 放大_小程序之争:支付宝、百度“放大招”,春节欲打突围战
  13. 【Android架构GPS篇】之定位数据如何从GPS芯片到应用层
  14. Linux ag命令
  15. 详解关系抽取模型 CasRel
  16. 局域网 如何连接主机_局域网远程操控电脑方法
  17. 转载 戴仁光:给专职站长的网络创业建议
  18. 一、无线通信中,工作频率与带宽的关系
  19. Vue 图片懒加载 v-lazy
  20. Mind Map - FreeMind

热门文章

  1. Android接入三方登录——QQ、微信、Facebook、Twitter
  2. 环境数据采集系统——中期总结
  3. python绝技:运用python成为顶级黑客
  4. 微信开发者工具调试公众号网页提示: 未绑定为公众号的网页开发者
  5. 前端CSS核心内容定位
  6. 计算机excel二进制,在Excel中实现二进制、八进制、十进制、十六进制之间的转换函数介绍...
  7. 让dede织梦显示最新文章前面加小图标
  8. Delphi访问网络共享文件夹
  9. 交换机常用命令——查看修改系统时间,查看交换机SN
  10. 推荐一款非常好用的API接口测试工具EoLink