gpt4 book ai didi

visual-c++ - 运行vcvars32.bat后如何重置环境

转载 作者:行者123 更新时间:2023-12-03 21:57:22 24 4
gpt4 key购买 nike

我正在编写一个批处理文件来使用 Visual C++ 运行一些构建。我想“撤消”脚本末尾的 vsvars32.bat/vcvarsXX.bat 更改,以便我在脚本运行之前保持环境不变。

示例 1 - 使用 vsvars32.bat

call %VS100COMNTOOLS%vsvars32.bat
devenv myProject.sln /Build "Debug|Win32"
:: Now undo vsvars32.bat

示例 2 - 使用 vcvars32.bat 和 vcvars64.bat
<path to VC bin>vcvars32.bat
:: cmd line build calls for 32 bit application
:: Now undo vcvars32.bat

<path to VC bin>amd64\vcvars64.bat
:: cmd line build calls for 64 bit application
:: Now undo vcvars64.bat

有什么建议么?

最佳答案

解决方案很简单 - SETLOCAL 与 ENDLOCAL 结合使用。输入 HELP SETLOCALHELP ENDLOCAL 以获取有关使用的更多信息。

示例 1:

setlocal
call %VS100COMNTOOLS%vsvars32.bat
devenv myProject.sln /Build "Debug|Win32"
endlocal

示例 2:
setlocal
<path to VC bin>vcvars32.bat
:: cmd line build calls for 32 bit application
endlocal

setlocal
<path to VC bin>amd64\vcvars64.bat
:: cmd line build calls for 64 bit application
endlocal

关于visual-c++ - 运行vcvars32.bat后如何重置环境,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14969399/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com