You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

便携版VSCode如何使用相对路径调用同USB内的便携版PowerShell

便携版VSCode调用同盘便携PowerShell相对路径配置方案

配置步骤

  • 打开VSCode,按下Ctrl+,(Windows)或Cmd+,(macOS)打开设置页,点击页面右上角的「打开设置(JSON)」按钮进入配置文件编辑界面。
  • 根据你的使用场景,添加对应的终端配置:

Windows系统单场景配置

如果仅在Windows下使用,添加如下配置:

"terminal.integrated.profiles.windows": {
    "便携PowerShell": {
        "path": "${env:VSCODE_PORTABLE}/../powershell/pwsh.exe",
        "args": []
    }
},
// 可选:将便携PowerShell设为默认终端
"terminal.integrated.defaultProfile.windows": "便携PowerShell"

说明:${env:VSCODE_PORTABLE}是便携版VSCode启动时自动生成的环境变量,固定指向VSCode根目录下的data文件夹。上述配置对应的目录结构为:VSCode根目录下直接存放powershell文件夹,内部包含pwsh.exe,如果你的目录层级不同,调整相对路径的../层级即可。

跨Windows/Linux/macOS多系统配置

如果需要在多系统下切换使用,分别添加对应系统的配置即可,相对路径规则通用:

// Windows配置
"terminal.integrated.profiles.windows": {
    "便携PowerShell": {
        "path": "${env:VSCODE_PORTABLE}/../powershell/pwsh.exe",
        "args": []
    }
},
"terminal.integrated.defaultProfile.windows": "便携PowerShell",
// Linux配置
"terminal.integrated.profiles.linux": {
    "便携PowerShell": {
        "path": "${env:VSCODE_PORTABLE}/../powershell/pwsh",
        "args": []
    }
},
"terminal.integrated.defaultProfile.linux": "便携PowerShell",
// macOS配置
"terminal.integrated.profiles.osx": {
    "便携PowerShell": {
        "path": "${env:VSCODE_PORTABLE}/../powershell/pwsh",
        "args": []
    }
},
"terminal.integrated.defaultProfile.osx": "便携PowerShell"
  • 保存配置文件后重启VSCode即可生效,后续无论U盘盘符如何变动,都可以正常调用同盘的便携PowerShell。

内容的提问来源于stack exchange,提问作者LightJack05

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.06 19:18:02