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

为何Launch-VsDevShell.ps1会修改工作目录?如何避免?

解决Launch-VsDevShell.ps1执行后更改工作目录的问题

直接给你解决办法:在执行Launch-VsDevShell.ps1时添加-SkipAutomaticLocation参数,就能只配置MSVC的环境变量,不会自动切换到默认的C:\Users\USERNAME\source\repos目录。

具体操作方式:

  • 直接在命令行执行:
    替换路径为你实际的VS安装路径(根据VS版本、版本类型调整,比如2019、Enterprise版路径会有差异):

    powershell -ExecutionPolicy Bypass -Command "& 'C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\Tools\Launch-VsDevShell.ps1' -SkipAutomaticLocation"
    
  • 在PowerShell脚本中调用:
    把路径改成你的VS对应路径就行:

    # 替换为你的Launch-VsDevShell.ps1实际路径
    $vsDevShellScript = "C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\Tools\Launch-VsDevShell.ps1"
    & $vsDevShellScript -SkipAutomaticLocation
    
  • 额外需求:指定编译架构:
    如果需要针对x64、x86等特定架构配置环境,可搭配-Arch参数:

    & $vsDevShellScript -SkipAutomaticLocation -Arch x64
    

内容的提问来源于stack exchange,提问作者Maxime Charrière

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.22 17:54:23