通用版
回头再搞
SES集训专用版
- A
# =============================================
# 定义所需文件及路径(请根据实际情况调整)
# =============================================
# MinGW 安装目录(用于添加环境变量,请确认该目录存在)
$MinGWTargetDir = "D:\mingw" # 改为你的 MinGW 实际路径
$MinGWBinDir = Join-Path -Path $MinGWTargetDir -ChildPath "bin"
# VS Code 可执行文件目录(用于安装扩展,请确认 code.cmd 所在路径)
$VSCodeBinDir = "D:\Programs\Microsoft VS Code\bin" # 若默认安装,可为 "$env:LOCALAPPDATA\Programs\Microsoft VS Code\bin"
# 扩展文件列表(需放在脚本同目录下)
$files = @(
"ms-vscode.cpptools-1.31.4-win32-x64.vsix",
"ms-ceintl.vscode-language-pack-zh-hans-1.110.2026041514.vsix",
"pomdtr.excalidraw-editor-3.9.1.vsix",
"shalldie.background-2.0.10.vsix",
"formulahendry.code-runner-0.12.2.vsix",
"yltx.vscode-luogu-4.14.0.vsix"
)
# 字体文件(需放在脚本同目录下)
$font = "FiraCode-Regular.ttf"
$fontFamily = "Fira Code"
# =============================================
# 1. 添加 MinGW 到系统环境变量 Path
# =============================================
Write-Host "--- 1. 添加 MinGW 到环境变量 ---" -ForegroundColor Cyan
if (-not (Test-Path $MinGWBinDir -PathType Container)) {
Write-Host "警告:MinGW 可执行目录 $MinGWBinDir 不存在,请确认路径正确。" -ForegroundColor Yellow
} else {
$CurrentPath = [Environment]::GetEnvironmentVariable("Path", "Machine")
if ($CurrentPath -clike "*$MinGWBinDir*") {
Write-Host "路径 $MinGWBinDir 已存在于系统 Path 中。" -ForegroundColor Yellow
} else {
Write-Host "正在添加 $MinGWBinDir 到系统 Path ..." -ForegroundColor Yellow
$NewPath = "$CurrentPath;$MinGWBinDir"
[Environment]::SetEnvironmentVariable("Path", $NewPath, "Machine")
Write-Host "Path 更新完成。新会话生效。" -ForegroundColor Green
}
}
# =============================================
# 2. 安装 Fira Code 字体
# =============================================
Write-Host "`n--- 2. 安装 Fira Code 字体 ---" -ForegroundColor Cyan
$dest = "C:\Windows\Fonts"
if (-not (Test-Path $font)) {
Write-Host "错误:字体文件 $font 未找到,跳过安装。" -ForegroundColor Red
} else {
Copy-Item $font -Destination "$dest\$font" -Force
$regPath = "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts"
New-ItemProperty -Path $regPath -Name "$fontFamily (TrueType)" -Value $font -PropertyType String -Force
# 加载字体到当前会话
Add-Type -TypeDefinition @"
using System;
using System.Runtime.InteropServices;
public class FontUtil {
[DllImport("gdi32.dll", EntryPoint="AddFontResourceW", SetLastError=true)]
public static extern int AddFontResource(string lpFileName);
[DllImport("user32.dll", SetLastError=true)]
public static extern int SendMessage(IntPtr hWnd, UInt32 Msg, IntPtr wParam, IntPtr lParam);
}
"@
[FontUtil]::AddFontResource("$dest\$font") | Out-Null
$HWND_BROADCAST = [intptr]0xffff
$WM_FONTCHANGE = 0x001D
[FontUtil]::SendMessage($HWND_BROADCAST, $WM_FONTCHANGE, [intptr]0, [intptr]0)
Write-Host "字体已安装并刷新系统。" -ForegroundColor Green
}
# =============================================
# 3. 安装 VS Code 扩展
# =============================================
Write-Host "`n--- 3. 安装 VS Code 扩展 ---" -ForegroundColor Cyan
# 检查 code 命令是否可用
$codeCmd = Join-Path -Path $VSCodeBinDir -ChildPath "code.cmd"
if (-not (Test-Path $codeCmd)) {
Write-Host "错误:未找到 code.cmd(路径:$codeCmd),请修改 `$VSCodeBinDir 变量。" -ForegroundColor Red
} else {
foreach ($f in $files) {
if (Test-Path $f) {
Write-Host "安装扩展:$f" -ForegroundColor Yellow
& $codeCmd --install-extension $f
} else {
Write-Host "警告:扩展文件 $f 不存在,跳过。" -ForegroundColor Yellow
}
}
# 关闭已打开的 VS Code,避免扩展加载冲突
try {
Get-Process -Name Code | Stop-Process -Force
Write-Host "已关闭正在运行的 VS Code。" -ForegroundColor Gray
} catch {}
}
# =============================================
# 4. 写入 VS Code 配置文件 (settings.json & argv.json)
# =============================================
Write-Host "`n--- 4. 配置 VS Code 设置 ---" -ForegroundColor Cyan
$content = @"
{
"editor.smoothScrolling": true,
"editor.cursorBlinking": "expand",
"editor.guides.bracketPairs": true,
"editor.bracketPairColorization.enabled": true,
"editor.acceptSuggestionOnEnter": "smart",
"editor.suggestSelection": "recentlyUsedByPrefix",
"editor.autoClosingBrackets": "beforeWhitespace",
"editor.autoClosingQuotes": "beforeWhitespace",
"editor.autoClosingDelete": "always",
"editor.autoClosingOvertype": "always",
"editor.fontSize": 18,
"editor.fontFamily": "'Fira Code', monospace",
"editor.fontLigatures": true,
"editor.formatOnSave": true,
"extensions.ignoreRecommendations": true,
"editor.mouseWheelZoom": true,
"editor.cursorSmoothCaretAnimation": "on",
"files.autoGuessEncoding": true,
"C_Cpp.clang_format_fallbackStyle": "{ColumnLimit: 70, BasedOnStyle: LLVM, IndentWidth: 4, TabWidth: 4 }",
"workbench.startupEditor": "none",
"security.workspace.trust.untrustedFiles": "open",
"C_Cpp.default.compilerPath": "D:/mingw/bin/g++.exe",
"files.associations": {
"*.cpp": "cpp"
},
"[cpp]": {
"editor.wordBasedSuggestions": "off",
"editor.semanticHighlighting.enabled": true,
"editor.stickyScroll.defaultModel": "foldingProviderModel",
"editor.suggest.insertMode": "replace"
},
"explorer.confirmDelete": false,
"json.format.keepLines": true,
"background.fullscreen": {
"images": [
// "https://upload-bbs.miyoushe.com/upload/2026/04/26/404580670/f9699cd0b02044a5c167b1efe554a088_6490500312537179773.jpg",
// "https://cdn.luogu.com.cn/upload/image_hosting/aiu0h201.png",
// "https://upload-bbs.miyoushe.com/upload/2024/01/18/311370925/de6edf6312b5c2ee4e0d14f70ba6234e_9009544746652854059.jpg"
"https://album.biliimg.com/bfs/new_dyn/4256c9b037af54280d186ef08a23e55f1349174610.jpg"
],
"opacity": 0.3,
"size": "cover",
"position": "center",
"interval": 60,
"random": true
},
"background.sidebar": { },
"background.panel": { },
"update.showReleaseNotes": false,
"background.enabled": true,
"excalidraw.theme": "auto",
"explorer.confirmDragAndDrop": false,
"workbench.browser.showInTitleBar": true,
"workbench.editor.empty.hint": "hidden",
"code-runner.runInTerminal": true,
"code-runner.executorMap": {
// 使用 python3 运行 Python 文件
"python": "python3 -u",
// 使用 g++ 编译并运行 C++ 文件
"cpp": "cd `$dir && g++ -Wall -Wextra -O2 `$fileName -o `$fileNameWithoutExt && `$dir`$fileNameWithoutExt",
// 使用 node 运行 JavaScript 文件
"javascript": "node",
// 使用 dotnet run 运行 C# 项目
"csharp": "cd `$dir && dotnet run"
}
}
"@
$argv = @"
{
"locale": "zh-cn",
"enable-crash-reporter": true,
"crash-reporter-id": "$([guid]::NewGuid().ToString())"
}
"@
$argvPath = "$env:USERPROFILE\.vscode\argv.json"
try{
$argv | Set-Content -Path $argvPath
}
catch{
Write-Host "错误详情:$($_.Exception.Message)" -ForegroundColor Red
}
$targetDir = "$env:APPDATA\Code\User"
$target = "$targetDir\settings.json"
# 如果目标目录不存在则创建
if (-not (Test-Path $targetDir)) {
New-Item -ItemType Directory -Path $targetDir | Out-Null
}
try{
$content | Set-Content -Path $target -Encoding UTF8
Write-Host "VSCode 安装完成并成功应用自定义设置" -ForegroundColor Green
}
catch{
Write-Host "错误详情:$($_.Exception.Message)" -ForegroundColor Red
}
Write-Host "`n--- 脚本执行完毕 ---" -ForegroundColor Cyan
pause
- B
# =============================================
# 定义所需文件及路径(请根据实际情况调整)
# =============================================
# MinGW 安装目录(用于添加环境变量,请确认该目录存在)
$MinGWTargetDir = "D:\mingw" # 改为你的 MinGW 实际路径
$MinGWBinDir = Join-Path -Path $MinGWTargetDir -ChildPath "bin"
# VS Code 可执行文件目录(用于安装扩展,请确认 code.cmd 所在路径)
$VSCodeBinDir = "D:\Programs\Microsoft VS Code\bin" # 若默认安装,可为 "$env:LOCALAPPDATA\Programs\Microsoft VS Code\bin"
# 扩展文件列表(需放在脚本同目录下)
$files = @(
"ms-vscode.cpptools-1.31.4-win32-x64.vsix",
"ms-ceintl.vscode-language-pack-zh-hans-1.110.2026041514.vsix",
"pomdtr.excalidraw-editor-3.9.1.vsix",
"shalldie.background-2.0.10.vsix",
"formulahendry.code-runner-0.12.2.vsix",
"yltx.vscode-luogu-4.14.0.vsix"
)
# 字体文件(需放在脚本同目录下)
$fonts = @(
"FiraCode-Regular.ttf",
"MapleMono-NF-CN-Medium.ttf"
)
# =============================================
# 1. 添加 MinGW 到系统环境变量 Path
# =============================================
Write-Host "--- 1. 添加 MinGW 到环境变量 ---" -ForegroundColor Cyan
if (-not (Test-Path $MinGWBinDir -PathType Container)) {
Write-Host "警告:MinGW 可执行目录 $MinGWBinDir 不存在,请确认路径正确。" -ForegroundColor Yellow
} else {
$CurrentPath = [Environment]::GetEnvironmentVariable("Path", "Machine")
if ($CurrentPath -clike "*$MinGWBinDir*") {
Write-Host "路径 $MinGWBinDir 已存在于系统 Path 中。" -ForegroundColor Yellow
} else {
Write-Host "正在添加 $MinGWBinDir 到系统 Path ..." -ForegroundColor Yellow
$NewPath = "$CurrentPath;$MinGWBinDir"
[Environment]::SetEnvironmentVariable("Path", $NewPath, "Machine")
Write-Host "Path 更新完成。新会话生效。" -ForegroundColor Green
}
}
# =============================================
# 2. 安装多个字体(使用 Shell.Application)
# =============================================
Write-Host "`n--- 2. 安装字体 ---" -ForegroundColor Cyan
# 加载 Shell.Application 用于安装字体
$shell = New-Object -ComObject Shell.Application
$fontsFolder = $shell.NameSpace(0x14) # 0x14 是 Fonts 文件夹的 CSIDL
foreach ($fontFile in $fonts) {
if (-not (Test-Path $fontFile)) {
Write-Host "警告:字体文件 $fontFile 不存在,跳过。" -ForegroundColor Yellow
continue
}
# 复制到 Fonts 目录(Shell 会自动注册)
$destFile = Join-Path "C:\Windows\Fonts" $fontFile
Copy-Item $fontFile -Destination $destFile -Force
# 使用 Shell 安装字体(推荐,会自动写入注册表)
$fontsFolder.CopyHere($destFile, 0x10) # 0x10 表示如果存在则替换
Write-Host "已安装字体:$fontFile" -ForegroundColor Green
}
# 发送字体更改通知(让正在运行的程序刷新字体列表)
Add-Type -TypeDefinition @"
using System;
using System.Runtime.InteropServices;
public class FontUtil {
[DllImport("user32.dll", SetLastError=true)]
public static extern int SendMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam);
}
"@
$HWND_BROADCAST = [intptr]0xffff
$WM_FONTCHANGE = 0x001D
[FontUtil]::SendMessage($HWND_BROADCAST, $WM_FONTCHANGE, [intptr]0, [intptr]0)
Write-Host "字体已安装并刷新系统。" -ForegroundColor Green
# =============================================
# 3. 安装 VS Code 扩展
# =============================================
Write-Host "`n--- 3. 安装 VS Code 扩展 ---" -ForegroundColor Cyan
# 检查 code 命令是否可用
$codeCmd = Join-Path -Path $VSCodeBinDir -ChildPath "code.cmd"
if (-not (Test-Path $codeCmd)) {
Write-Host "错误:未找到 code.cmd(路径:$codeCmd),请修改 `$VSCodeBinDir 变量。" -ForegroundColor Red
} else {
foreach ($f in $files) {
if (Test-Path $f) {
Write-Host "安装扩展:$f" -ForegroundColor Yellow
& $codeCmd --install-extension $f
} else {
Write-Host "警告:扩展文件 $f 不存在,跳过。" -ForegroundColor Yellow
}
}
# 关闭已打开的 VS Code,避免扩展加载冲突
try {
Get-Process -Name Code | Stop-Process -Force
Write-Host "已关闭正在运行的 VS Code。" -ForegroundColor Gray
} catch {}
}
# =============================================
# 4. 写入 VS Code 配置文件 (settings.json & argv.json)
# =============================================
Write-Host "`n--- 4. 配置 VS Code 设置 ---" -ForegroundColor Cyan
$content = @"
{
"editor.smoothScrolling": true,
"editor.cursorBlinking": "expand",
"editor.guides.bracketPairs": true,
"editor.bracketPairColorization.enabled": true,
"editor.acceptSuggestionOnEnter": "smart",
"editor.suggestSelection": "recentlyUsedByPrefix",
"editor.autoClosingBrackets": "beforeWhitespace",
"editor.autoClosingQuotes": "beforeWhitespace",
"editor.autoClosingDelete": "always",
"editor.autoClosingOvertype": "always",
"editor.fontSize": 18,
"editor.fontFamily": "'Fira Code', monospace",
"editor.fontLigatures": true,
"editor.formatOnSave": true,
"extensions.ignoreRecommendations": true,
"editor.mouseWheelZoom": true,
"editor.cursorSmoothCaretAnimation": "on",
"files.autoGuessEncoding": true,
"C_Cpp.clang_format_fallbackStyle": "{ColumnLimit: 70, BasedOnStyle: LLVM, IndentWidth: 4, TabWidth: 4 }",
"workbench.startupEditor": "none",
"security.workspace.trust.untrustedFiles": "open",
"C_Cpp.default.compilerPath": "D:/mingw/bin/g++.exe",
"files.associations": {
"*.cpp": "cpp"
},
"[cpp]": {
"editor.wordBasedSuggestions": "off",
"editor.semanticHighlighting.enabled": true,
"editor.stickyScroll.defaultModel": "foldingProviderModel",
"editor.suggest.insertMode": "replace"
},
"explorer.confirmDelete": false,
"json.format.keepLines": true,
"background.fullscreen": {
"images": [
// "https://upload-bbs.miyoushe.com/upload/2026/04/26/404580670/f9699cd0b02044a5c167b1efe554a088_6490500312537179773.jpg",
// "https://cdn.luogu.com.cn/upload/image_hosting/aiu0h201.png",
// "https://upload-bbs.miyoushe.com/upload/2024/01/18/311370925/de6edf6312b5c2ee4e0d14f70ba6234e_9009544746652854059.jpg"
"https://album.biliimg.com/bfs/new_dyn/4256c9b037af54280d186ef08a23e55f1349174610.jpg"
],
"opacity": 0.3,
"size": "cover",
"position": "center",
"interval": 60,
"random": true
},
"background.sidebar": { },
"background.panel": { },
"update.showReleaseNotes": false,
"background.enabled": true,
"excalidraw.theme": "auto",
"explorer.confirmDragAndDrop": false,
"workbench.browser.showInTitleBar": true,
"workbench.editor.empty.hint": "hidden",
"code-runner.runInTerminal": true,
"code-runner.executorMap": {
// 使用 python3 运行 Python 文件
"python": "python3 -u",
// 使用 g++ 编译并运行 C++ 文件
"cpp": "cd `$dir && g++ -Wall -Wextra -O2 `$fileName -o `$fileNameWithoutExt && `$dir`$fileNameWithoutExt",
// 使用 node 运行 JavaScript 文件
"javascript": "node",
// 使用 dotnet run 运行 C# 项目
"csharp": "cd `$dir && dotnet run"
}
}
"@
$argv = @"
{
"locale": "zh-cn",
"enable-crash-reporter": true,
"crash-reporter-id": "$([guid]::NewGuid().ToString())"
}
"@
$argvPath = "$env:USERPROFILE\.vscode\argv.json"
try{
$argv | Set-Content -Path $argvPath
}
catch{
Write-Host "错误详情:$($_.Exception.Message)" -ForegroundColor Red
}
$targetDir = "$env:APPDATA\Code\User"
$target = "$targetDir\settings.json"
# 如果目标目录不存在则创建
if (-not (Test-Path $targetDir)) {
New-Item -ItemType Directory -Path $targetDir | Out-Null
}
try{
$content | Set-Content -Path $target -Encoding UTF8
Write-Host "VSCode 安装完成并成功应用自定义设置" -ForegroundColor Green
}
catch{
Write-Host "错误详情:$($_.Exception.Message)" -ForegroundColor Red
}
Write-Host "`n--- 脚本执行完毕 ---" -ForegroundColor Cyan
pause
- D
# =============================================
# 定义所需文件及路径
# =============================================
# MinGW 安装目录
$MinGWTargetDir = "D:\mingw"
$MinGWBinDir = Join-Path -Path $MinGWTargetDir -ChildPath "bin"
# VS Code 可执行文件目录(用于安装扩展,请确认 code.cmd 所在路径)
$VSCodeBinDir = "D:\Programs\Microsoft VS Code\bin"
# 扩展文件列表
$files = @(
"ms-vscode.cpptools-1.31.4-win32-x64.vsix",
"ms-ceintl.vscode-language-pack-zh-hans-1.110.2026041514.vsix",
"pomdtr.excalidraw-editor-3.9.1.vsix",
"shalldie.background-2.0.10.vsix",
"formulahendry.code-runner-0.12.2.vsix",
"yltx.vscode-luogu-4.14.0.vsix"
)
# 字体文件
$fonts = @(
"MapleMono-NF-CN-Medium.ttf",
"FiraCode-Regular.ttf"
)
# =============================================
# 1. 添加 MinGW 到系统环境变量 Path
# =============================================
Write-Host "--- 1. 添加 MinGW 到环境变量 ---" -ForegroundColor Cyan
if (-not (Test-Path $MinGWBinDir -PathType Container)) {
Write-Host "警告:MinGW 可执行目录 $MinGWBinDir 不存在,请确认路径正确。" -ForegroundColor Yellow
} else {
$CurrentPath = [Environment]::GetEnvironmentVariable("Path", "Machine")
if ($CurrentPath -clike "*$MinGWBinDir*") {
Write-Host "路径 $MinGWBinDir 已存在于系统 Path 中。" -ForegroundColor Yellow
} else {
Write-Host "正在添加 $MinGWBinDir 到系统 Path ..." -ForegroundColor Yellow
$NewPath = "$CurrentPath;$MinGWBinDir"
[Environment]::SetEnvironmentVariable("Path", $NewPath, "Machine")
Write-Host "Path 更新完成。新会话生效。" -ForegroundColor Green
}
}
# =============================================
# 2. 安装多个字体(使用 Shell.Application)
# =============================================
Write-Host "`n--- 2. 安装字体 ---" -ForegroundColor Cyan
# 加载 Shell.Application 用于安装字体
$shell = New-Object -ComObject Shell.Application
$fontsFolder = $shell.NameSpace(0x14) # 0x14 = Fonts 文件夹
foreach ($fontFile in $fonts) {
$fullPath = Join-Path $PSScriptRoot $fontFile # 使用绝对路径更可靠
if (-not (Test-Path $fullPath)) {
Write-Host "警告:字体文件 $fontFile 不存在,跳过。" -ForegroundColor Yellow
continue
}
try {
# CopyHere 会自动完成复制+注册,无需手动复制
$fontsFolder.CopyHere($fullPath, 0x10) # 0x10 = 覆盖已存在文件
Write-Host "已安装字体:$fontFile" -ForegroundColor Green
} catch {
Write-Host "安装字体失败:$($_.Exception.Message)" -ForegroundColor Red
}
}
# 发送字体更改通知(让正在运行的程序刷新字体列表)
Add-Type -TypeDefinition @"
using System;
using System.Runtime.InteropServices;
public class FontUtil {
[DllImport("user32.dll", SetLastError=true)]
public static extern int SendMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam);
}
"@
$HWND_BROADCAST = [intptr]0xffff
$WM_FONTCHANGE = 0x001D
[FontUtil]::SendMessage($HWND_BROADCAST, $WM_FONTCHANGE, [intptr]0, [intptr]0)
Write-Host "字体已安装并刷新系统。" -ForegroundColor Green
# =============================================
# 3. 安装 VS Code 扩展
# =============================================
Write-Host "`n--- 3. 安装 VS Code 扩展 ---" -ForegroundColor Cyan
# 检查 code 命令是否可用
$codeCmd = Join-Path -Path $VSCodeBinDir -ChildPath "code.cmd"
if (-not (Test-Path $codeCmd)) {
Write-Host "错误:未找到 code.cmd(路径:$codeCmd),请修改 `$VSCodeBinDir 变量。" -ForegroundColor Red
} else {
foreach ($f in $files) {
if (Test-Path $f) {
Write-Host "安装扩展:$f" -ForegroundColor Yellow
& $codeCmd --install-extension $f
} else {
Write-Host "警告:扩展文件 $f 不存在,跳过。" -ForegroundColor Yellow
}
}
# 关闭已打开的 VS Code,避免扩展加载冲突
try {
Get-Process -Name Code | Stop-Process -Force
Write-Host "已关闭正在运行的 VS Code。" -ForegroundColor Gray
} catch {}
}
# =============================================
# 4. 写入 VS Code 配置文件 (settings.json & argv.json)
# =============================================
Write-Host "`n--- 4. 配置 VS Code 设置 ---" -ForegroundColor Cyan
$content = @"
{
"editor.smoothScrolling": true,
"editor.cursorBlinking": "expand",
"editor.guides.bracketPairs": true,
"editor.bracketPairColorization.enabled": true,
"editor.acceptSuggestionOnEnter": "smart",
"editor.suggestSelection": "recentlyUsedByPrefix",
"editor.autoClosingDelete": "always",
"editor.autoClosingOvertype": "always",
"editor.fontSize": 18,
"editor.fontFamily": "'Maple Mono NF CN Medium','Fira Code', monospace",
"editor.fontLigatures": true,
"editor.formatOnSave": true,
"extensions.ignoreRecommendations": true,
"editor.mouseWheelZoom": true,
"editor.cursorSmoothCaretAnimation": "on",
"files.autoGuessEncoding": true,
"C_Cpp.clang_format_fallbackStyle": "{ColumnLimit: 70, BasedOnStyle: LLVM, IndentWidth: 4, TabWidth: 4 }",
"workbench.startupEditor": "none",
"security.workspace.trust.untrustedFiles": "open",
"C_Cpp.default.compilerPath": "D:/mingw/bin/g++.exe",
"files.associations": {
"*.cpp": "cpp"
},
"[cpp]": {
"editor.wordBasedSuggestions": "off",
"editor.semanticHighlighting.enabled": true,
"editor.stickyScroll.defaultModel": "foldingProviderModel",
"editor.suggest.insertMode": "replace"
},
"explorer.confirmDelete": false,
"json.format.keepLines": true,
"background.fullscreen": {
"images": [
// "https://upload-bbs.miyoushe.com/upload/2026/04/26/404580670/f9699cd0b02044a5c167b1efe554a088_6490500312537179773.jpg",
// "https://cdn.luogu.com.cn/upload/image_hosting/aiu0h201.png",
// "https://upload-bbs.miyoushe.com/upload/2024/01/18/311370925/de6edf6312b5c2ee4e0d14f70ba6234e_9009544746652854059.jpg"
"https://album.biliimg.com/bfs/new_dyn/4256c9b037af54280d186ef08a23e55f1349174610.jpg"
],
"opacity": 0.3,
"size": "cover",
"position": "center",
"interval": 60,
"random": true
},
"background.sidebar": { },
"background.panel": { },
"update.showReleaseNotes": false,
"background.enabled": true,
"excalidraw.theme": "auto",
"explorer.confirmDragAndDrop": false,
"workbench.browser.showInTitleBar": true,
"workbench.editor.empty.hint": "hidden",
"code-runner.runInTerminal": true,
"code-runner.executorMap": {
"python": "python3 -u",
"cpp": "cd `$dir && g++ -Wall -Wextra -O2 `$fileName -o `$fileNameWithoutExt && `$dir`$fileNameWithoutExt",
"javascript": "node",
"csharp": "cd `$dir && dotnet run"
}
}
"@
$argv = @"
{
"locale": "zh-cn",
"enable-crash-reporter": true,
"crash-reporter-id": "$([guid]::NewGuid().ToString())"
}
"@
$argvPath = "$env:USERPROFILE\.vscode\argv.json"
try{
$argv | Set-Content -Path $argvPath
}
catch{
Write-Host "错误详情:$($_.Exception.Message)" -ForegroundColor Red
}
$targetDir = "$env:APPDATA\Code\User"
$target = "$targetDir\settings.json"
# 如果目标目录不存在则创建
if (-not (Test-Path $targetDir)) {
New-Item -ItemType Directory -Path $targetDir | Out-Null
}
try{
$content | Set-Content -Path $target -Encoding UTF8
Write-Host "VSCode 安装完成并成功应用自定义设置" -ForegroundColor Green
}
catch{
Write-Host "错误详情:$($_.Exception.Message)" -ForegroundColor Red
}
Write-Host "`n--- 脚本执行完毕 ---" -ForegroundColor Cyan
pause