通过 PowerShell
来扩展 Path
环境变量,具体命令如下:
1. 以管理员身份运行 PowerShell
确保你以管理员身份运行 PowerShell,因为设置全局环境变量需要管理员权限。
2. 扩展 Path
环境变量
首先,你可以尝试在当前会话中扩展 Path
环境变量:
$env:Path += ";D:\vcpkg\installed\x64-windows\tools\protobuf"
Write-Host "Updated Path: $($env:Path)"
3. 设置全局环境变量
要将路径永久添加到系统级别的 Path
环境变量中,可以使用以下命令:
[System.Environment]::SetEnvironmentVariable("Path", $env:Path, [System.EnvironmentVariableTarget]::Machine)