vs2012 无法使用命令行提示符?ERROR: Cannot determine the location of the VS Common Tools folder.

vs2012 无法使用命令行提示符?

提示:
ERROR: Cannot determine the location of the VS Common Tools folder.

百度了很多方法,都是直接修改 vcvars32.bat 文件指定具体路径:

VS2012命令提示符无法使用的解决方法

打开VS2012命令提示符时报错“ ERROR: Cannot determine the location of the VS Common Tools folder.”

 

解决方法:

1.打开计算机->属性->高级系统设置

2.新建变量VS110COMNTOOLS,属性值设置为C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\Tools\

3.打开编译VC\bin目录下的vcvars32.bat文件,在第一行添加下列语句:

   @echo Setting environment for using Microsoft Visual Studio 2012 x64 tools
   @SET VSINSTALLDIR=c:\Program Files\Microsoft Visual Studio 11.0
   @SET VCINSTALLDIR=c:\Program Files\Microsoft Visual Studio 11.0\VC 
   @SET FrameworkDir32=c:\Windows\Microsoft.NET\Framework
   @SET FrameworkVersion32=v4.0.30319
   @SET Framework35Version=v3.5

  并注释掉下列语句:

   ::@call :GetVSCommonToolsDir
   ::@if "%VS110COMNTOOLS%"=="" goto error_no_VS110COMNTOOLSDIR

   ::@call "%VS110COMNTOOLS%VCVarsQueryRegistry.bat" 32bit No64bit


根本原因:公司禁用了注册表编辑器


查看 vcvars32.bat 代码,可以看到,它使用reg命令从注册表取路径。由于禁用了注册表编辑器,reg无法运行。所以取不到路径。
:GetVSCommonToolsDir
@set VS110COMNTOOLS=
@call :GetVSCommonToolsDirHelper32 HKLM > nul 2>&1
@if errorlevel 1 call :GetVSCommonToolsDirHelper32 HKCU > nul 2>&1
@if errorlevel 1 call :GetVSCommonToolsDirHelper64 HKLM > nul 2>&1
@if errorlevel 1 call :GetVSCommonToolsDirHelper64 HKCU > nul 2>&1
@exit /B 0
:GetVSCommonToolsDirHelper32
@for /F "tokens=1,2*" %%i in (' reg query "%1\SOFTWARE\Microsoft\VisualStudio\SxS\VS7" /v "11.0"') DO (
 @if "%%i"=="11.0" (
  @SET "VS110COMNTOOLS=%%k"
 )
)
@if "%VS110COMNTOOLS%"=="" exit /B 1
@SET "VS110COMNTOOLS=%VS110COMNTOOLS%Common7\Tools\"
@exit /B 0


解决办法:
取消禁用注册表编辑器!
  • 1
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 7
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 7
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值