Nice programing

VS2010 명령 프롬프트에서 오류 발생 : VS Common Tools 폴더의 위치를 ​​확인할 수 없습니다.

nicepro 2020. 11. 10. 22:14
반응형

VS2010 명령 프롬프트에서 오류 발생 : VS Common Tools 폴더의 위치를 ​​확인할 수 없습니다.


VS2010을 설치했습니다. 설치하면 VS2010 명령 프롬프트의 바로 가기가 생성되지만 명령 프롬프트를 열면 오류가 발생합니다.

VS Common Tools 폴더의 위치를 ​​확인할 수 없습니다.

환경 변수 VS100COMNTOOLS를 확인했는데 값이 C:\Program Files\Microsoft Visual Studio 10.0\Common7\Tools\있고 레지스트리 HKEY_local_Machine\Software\Microsoft\Visual Studio\SxS\VS7가로 설정되어 C:\Program Files\Microsoft Visual Studio 10.0\있습니다.

나는 VSvars32.bat를 확인하고 그것이 진행될 때까지 찾기 위해 에코를 추가하려고했습니다. 다음 명령에서 실패합니다.

@call :GetVSCommonToolsDirHelper32 HKLM > nul 2>&1

나는 같은 문제가 있었고 여기 에서 답을 찾았습니다 .

문제는 bat가 de reg 명령을 사용 하고 PATH 시스템 변수에서 검색한다는 것입니다. 어떻게 든 PATH 변수에서 "C : \ Windows \ System32"를 얻었으므로 시스템 변수로 이동하십시오 ( "내 컴퓨터"> "속성"> 고급 구성> "환경 변수"를 마우스 오른쪽 단추로 클릭하고 PATH 검색). 변수를 추가하고 끝에 " ; "로 구분하여 추가합니다 . C : \ Windows \ System32


두 컴퓨터에서 동일한 문제가 발생했습니다. Visual Studio Ultimate 2013 (VS2013)이 설치된 Win8.1x64 및 VS2013 ultimate이있는 Win8x64

문제 : C : \ Program Files (x86) \ Microsoft Visual Studio 11.0 을 호출하는 C : \ Program Files (x86) \ Microsoft Visual Studio 11.0 \ VC \ vcvarsall.bat 파일을 가리키는 바로 가기 " VS2012 x86 기본 도구 명령 프롬프트 " \ VC \ bin \ vcvars32.bat 는 레지스트리에서 값 이름 "11.0"을 검색하려고합니다.

reg query "%1\SOFTWARE\Microsoft\VisualStudio\SxS\VS7" /v "11.0"

그러나 내 컴퓨터에는이 값 "11.0" 이없고 대신 "12.0"이 있습니다.

내 솔루션은 올바르게 쿼리하는 C : \ Program Files (x86) \ Microsoft Visual Studio 12.0 \ VC \ bin \ vcvars32.bat호출 하는 C : \ Program Files (x86) \ Microsoft Visual Studio 12.0 \ VC \ vcvarsall.bat 를 실행 하는 것입니다. 다음과 같이 레지스트리 :

reg query "%1\SOFTWARE\Microsoft\VisualStudio\SxS\VS7" /v "12.0"

그래서 C : \ Program Files (x86) \ Microsoft Visual Studio 11.0 \ VC \ vcvarsall.bat 에서 C : \ Program Files (x86) \ Microsoft Visual Studio 12.0 \ VC \ vcvarsall.bat로 변경 / 실행 하면 제 경우에는 해결되었습니다.


이 같은 문제가 방금 발생하기 시작했으며 C : \ Program Files (x86) \ Microsoft Visual Studio 10.0 \ VC \ bin \ 폴더 (기본적으로)에있는 vcvars32.bat 파일을 업데이트하여 "수정"할 수있었습니다. . 첫 번째 줄 뒤에 다음을 추가합니다.

@SET VSINSTALLDIR=c:\Program Files\Microsoft Visual Studio 10.0\
@SET VCINSTALLDIR=c:\Program Files\Microsoft Visual Studio 10.0\VC\
@SET FrameworkDir32=c:\Windows\Microsoft.NET\Framework\
@SET FrameworkVersion32=v4.0.30319
@SET Framework35Version=v3.5

그리고 다음 줄을 주석 처리하십시오.

:: @call :GetVSCommonToolsDir
:: @if "%VS100COMNTOOLS%"=="" goto error_no_VS100COMNTOOLSDIR
:: @call "%VS100COMNTOOLS%VCVarsQueryRegistry.bat" 32bit No64bit

여기 에서 찾았 습니다 . 모든 적절한 변수가 올바르게 설정되었는지 확인하지 않았기 때문에 따옴표로 수정한다고 말합니다. 즉, 피상적으로 볼 때 유효한 것으로 보입니다.

Vista 및 Windows 7에서 파일을 저장할 수 있으려면 관리자 권한 텍스트 편집기 (예 : 관리자 권한으로 실행)에서 vcvars32.bat 파일을 편집해야합니다.


제 경우의 문제는 PATH 변수의 오타였습니다. vsvars32.bat는 "reg"도구를 사용하여 레지스트리를 쿼리하기 때문에 도구를 찾을 수 없기 때문에 실패했습니다 ( reg명령 프롬프트에 입력 하는 것이 실패했습니다).


훌륭한 게시물입니다. vcvarsall.bat 파일을 모두 변경하기 전에 관리자 권한으로 vs2010 명령 프롬프트를 실행 해보십시오. 그래도 문제가 해결되지 않으면 C : \ Windows \ System32를 PATH 환경 변수에 추가해보십시오. 다른 모든 방법이 실패하면 위에서 설명한대로 배치 파일을 편집합니다.


얼마 전에 그룹 정책에 의해 레지스트리 편집이 차단 된 결과이 문제가 발생했습니다.

구체적인 문제는 reg가 레지스트리에 대한 액세스를 거부한다는 것입니다. Microsoft.Win32.RegistryC # 프로그램에서 사용하는 'reg.exe'를 복제 한 다음 모든 reg 호출을 대체 프로그램으로 대체 하여이 문제를 해결했습니다 . 업데이트해야합니다.

  • VCVarsQuery.bat
  • VsDevCmd.bat
  • VsVars32.bat

에서 %VSxxxCOMNTOOLS%폴더 (일반적으로 C 같은 것으로 해결 : \의 Program Files (x86) \ 마이크로 소프트 비주얼 스튜디오 XX.X \ Common7 \ 도구)

    static int Main(string[] args)
    {
        try
        {
            var targetRegistry = args[1].Substring(0, 4);
            var targetKey = args[1].Substring(5);

            string targetValue = null;
            if (args[2].ToLower() == "/v")
            {
                targetValue = args[3];
            }
            else
            {
                return 1;
            }

            var hkey = targetRegistry == "HKLM" ? Registry.LocalMachine : Registry.CurrentUser;
            var key = hkey.OpenSubKey(targetKey);



            var result = key.GetValue(targetValue);
            Console.WriteLine();
            Console.WriteLine(key.Name);
            Console.WriteLine("    {0}    REG_SZ    {2}", targetValue, key.GetValueKind(targetValue), result);
            Console.WriteLine();
            Console.WriteLine();

            return 0;
        }
        catch
        {
            return 1;
        }
    }

이와 같은 경우 여기에서 대체 reg구현을 사용할 수도 있습니다 .


나는 같은 문제에 직면했다. 'PATH'변수에 대한 환경 변수를 조사했지만 이것을 찾을 수 없었습니다. 그런 다음 "C : \ Windows \ System32"값이있는 변수 'Path'를 추가했습니다. 이제 모든 것이 해결되었습니다.


경로를 컴퓨터의 올바른 위치로 지정하십시오. 이 설정은 대부분의 프로그램이 중앙 위치 (C : \ Development)에 설치되어 있다고 가정합니다. 내 사용을 위해 DEV의 필요성을 제거하지 않았습니다.

@ECHO OFF

set DEV=C:\Development
set QTDIR=%DEV%\Qt
set PATH=%SystemRoot%;%SystemRoot%\system32;%QTDIR%\bin

echo Setting OpenSSL Env.
set OPENSSL=%DEV%\OpenSSL
set PATH=%OPENSSL%\bin;%PATH%
set LIB=%OPENSSL%\lib
set INCLUDE=%OPENSSL%\include

echo Setting NASM Env.
set PATH=%DEV%\NASM;%PATH%

echo Setting DirectX Env.
set LIB=%DEV%\DirectX SDK\Lib\x86;%LIB%
set INCLUDE=%DEV%\DirectX SDK\Include;%INCLUDE%

echo Setting Windows SDK Env.
set WindowsSdkDir=%DEV%\Windows 7.1 SDK
set PATH=%WindowsSdkDir%\Bin;%PATH%
set LIB=%WindowsSdkDir%\Lib;%LIB%
set INCLUDE=%WindowsSdkDir%\Include;%INCLUDE%
set TARGET_CPU=x86

echo Setting MSVC2010 Env.
set VSINSTALLDIR=%DEV%\MSVC
set VCINSTALLDIR=%DEV%\MSVC\VC
set DevEnvDir=%VSINSTALLDIR%\Common7\IDE
set PATH=%VCINSTALLDIR%\bin;%VSINSTALLDIR%\Common7\Tools;%VSINSTALLDIR%\Common7\IDE;%VCINSTALLDIR%\VCPackages;%PATH%
set INCLUDE=%VCINSTALLDIR%\include;%INCLUDE%
set LIB=%VCINSTALLDIR%\lib;%LIB%
set LIBPATH=%VCINSTALLDIR%\lib

echo Setting Framework Env.
set FrameworkVersion=v4.0.30319
set Framework35Version=v3.5
set FrameworkDir=%SystemRoot%\Microsoft.NET\Framework
set LIBPATH=%FrameworkDir%\%FrameworkVersion%;%FrameworkDir%\%Framework35Version%;%LIBPATH%
set PATH=%LIBPATH%;%PATH%

echo Setting Perl Env.
set PATH = C:\Perl\bin;%PATH%

echo Env. ready.

title Qt Framework 4.8.0 Development Kit.

cd %DEV%

* .bat로 파일 저장

Visual Studio 명령 프롬프트를 실행 한 다음 * .bat를 실행합니다.

이렇게하면 모든 환경 문제가 해결되므로 configure를 실행하십시오.

편집 신용이 필요한 곳에서 신용을 거의 잊어 버렸습니다. http://developer.qt.nokia.com/wiki/Building_Qt_Desktop_for_Windows_with_MSVC


나는 같은 문제가 있지만 다른 이유가 있습니다. 현재 디렉토리에 "reg.bat"가 있습니다. 다른 이름으로 이름을 바꾸면 문제가 해결되었습니다.


그래서이 스레드의 모든 문제의 근본 원인을 알아 냈습니다. 원래 2010에만 해당한다고 생각했지만 2013의 배치 파일에는 동일한 토큰 구문 분석 구문 오류가 있습니다. 기본적으로 MS가 2010 년부터 2013 년까지 컴파일러와 함께 배포하는 모든 배치 파일에는 동일한 오류가 있습니다. 모든 .bat 파일에서이 문자열을 검색하는 경우

"%%i"

그리고 그것을

"%%j"

everything will work correctly. Basically they are trying to query the registry for different version entries to get the correct paths to use. They create a for loop that will iterate over the tokens from each line that the query pulls. There are three tokens that should come back. They use %%i for the first one which would be REG_SZ, to see if something was found. Then they use the same one to compare against a version string. They should be using %%j to get the second token which would be 8.0 or 10.0 or 12.0 and would actually yield a good comparison. Then they correctly use %%k to get the path associated with the version.

Again, do the simple search and replace in all the files that have a pattern like this:

@for /F "tokens=1,2*" %%i in ('reg query "%1\SOFTWARE\Microsoft\VisualStudio\SxS\VS7" /v "12.0"') DO (
    @if "%%i"=="12.0" (
        @SET "VS120COMNTOOLS=%%k"
    )
)

and make it look like this:

@for /F "tokens=1,2*" %%i in ('reg query "%1\SOFTWARE\Microsoft\VisualStudio\SxS\VS7" /v "12.0"') DO (
    @if "%%j"=="12.0" (
        @SET "VS120COMNTOOLS=%%k"
    )
)

by changing the second occurrence of %%i, which is in quotes, to %%j.

Hope this helps!


The same problem occurred for me when iI was installing a python library and it said unable to find the path of Visual Studio 2008/10. I have change the PATH from environmental variables. So to change it you the following process can be adopted: Start=> Computer=>Properties=>Advance System Settings=>Environment Variables=>System Variables. Here you will find path variable. If some already some path is set then you can use semicolon(;) to add the given path "C:\Windows\System32" else directly add the same.


I was getting the same error when trying to run a publish process through powershell on my build machine.

My build machine only has the Windows SDK installed and not Visual Studio and as such it appears that I'm missing some common files and registry values that are normally present when Visual Studio is installed. After looking into vsvars32.bat a bit more carefully I noticed that it was where the "Cannot determine the location of the VS Common Tools folder" error was being reported located under the GetVSCommonToolsDir label. It appears that in this batch file that since the VS7 sub-key doesn't exist on my machine it blanks out the %VS100COMNTOOLS% environment variable and reports back the specified error.

In my case it appears that this error is happening for me because I don't have Visual Studio or some other necessary components installed on my build machine and thus the registry key doesn't exist. Perhaps your error is due to something similar such as 32-bit vs 64-bit registry or 32-bit vs 64-bit VS command prompt? Testing the line of code that is failing from the batch directly in the command prompt should give you a clue about why the registry or file path isn't being resolved properly.


I had this problem when I installed something that created a user environment PATH variable. My TeamCity build agent was running as a service under my own username and it found the user PATH variable instead of the machine PATH variable. With the wrong path variable, it couldn't find much of anything and gave this error.


For me, this was caused by the PATH environment variable being set to an empty value for my user profile. The system variable was set correctly, so I deleted the blank PATH variable from my profile and everything worked again.


I got a gnarly beast working with only the Microsoft Windows SDK v7.1 batch file SetEnv.Cmd -- ie: I do not have Visual Studio vAny installed and did not have to use any of the specially prepared cmd prompts (where vsvars32.bat et al rear their ugly heads). I just have the Microsoft Windows SDK for Windows 7 (7.1) installed with their C/C++ compilers. On my Xp64 box, this is the sequence I used to be able to compile one of the June 2010 DirectX SDK Audio samples :

REM open a regular old cmd.exe and run these 3
REM this builds the Win32 (ie: x86) version of the exe

cd "C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Samples\C++\XACT\Tutorials\Tut02_Stream"

"C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\SetEnv.Cmd" /debug /x86 /xp

"C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe" Tut02_Stream_2010.sln /p:Configuration=Debug /p:Platform=Win32

Note that using the Framework64 version of MSBuild.exe prevents me from building the X64 version (due to targets?), but the X86 version of MSBuild successfully built the X64 version of the same tutorial exe:

REM open a regular old cmd.exe and run these 3
REM this builds the X64 version of the exe

cd "C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Samples\C++\XACT\Tutorials\Tut02_Stream"

"C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\SetEnv.Cmd" /debug /x64 /2003

"C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe" Tut02_Stream_2010.sln /p:Configuration=Debug /p:Platform=X64

I also have faced the same issue. Initially tried modifying System PATH which does not worked out. Later resolved by installing Micro Visual Studio express.


I ran into this same problem while doing a build on our Windows 7 build system. I was filling in for our build engineer's absence, and it was the first time I've done it since we migrated from Windows XP to Windows 7 32-bit. The IT requirements for our build system have locked the permissions down to where it's very difficult to do the most routine operations. As it turns out, the problem was due to a lack of elevated privileges. By closing Visual Studio 2010 and re-opening it with administrator rights (Run as Administrator), the problem was fixed.


So this is probably waaaaaay late to the party but the actual problem is an error or rather the repetition of the same error in three batch files.

C:\Program Files(x86)\Microsoft Visual Studio 10.0\Common7\Tools\VCVarsQueryRegistry.bat

C:\Program Files(x86)\Microsoft Visual Studio 10.0\Common7\Tools\vsvars32.bat

C:\Program Files(x86)\Microsoft Visual Studio 10.0\VC\bin\vcvars32.bat

The pattern of the error is everywhere a for loop is used to loop through registry values. It looks like this:

@for /F "tokens=1,2*" %%i in ('reg query "%1\SOFTWARE\Microsoft\VisualStudio\SxS\VS7" /v "10.0"') DO (
    @if "%%i"=="10.0" (
        @SET "VS100COMNTOOLS=%%k"
    )
)

The problem is the second occurrence of %%i. The way the loop construct works is the first %% variable is the first token, the next is the second and so on. So the second %%i should be a %%j (or whatever you want) so that it points to the value that would possibly be a "10.0". You can tell the developer wanted to use i,j,k as the values because in the enclosed @SET in the if, they use %%k. Which would be the path.

So, in short, go through all these types of loops in the three files above and change the second occurrence of %%i to %%k and everything will work like it's supposed to. So it should look like this:

@for /F "tokens=1,2*" %%i in ('reg query "%1\SOFTWARE\Microsoft\VisualStudio\SxS\VS7" /v "10.0"') DO (
    @if "%%j"=="10.0" (
        @SET "VS100COMNTOOLS=%%k"
    )
)

Hope this helps. Not sure if this applies to all versions. I only know that it does apply to VS 2010 (SP1).


None of the above fixed my problem.

I added "C:/Windows/System32" to the 'Path' or 'PATH' environment variable. I could use the reg /? command. I also ran the 'vcvarsall.bat' file with no error message.

My error is that I was running VS2012 Cross Tools Command Prompt instead of VS2013 Cross Tools Command Prompt.

The reason being the file structure in the start menu. 2010 and 2012 are under 'Microsoft Visual Studio YEAR' and 2013 is under 'Visual Studio YEAR'. I just didn't realize this. :/

I hope this helps someone.


In my case I'd install VS.Net 2015 update 2 and left the Windows 8.1 SDK box UNchecked (since I'm now using Windows 10 and didn't think it necessary). However that seems to have resulted in some required registry settings being omitted.

Doing a modify of VS.Net 2015 from the control panel and checking the 8.1 SDK box fixed the problem.


Another cause can be VS 2013 Community Update 5 installing the WRONG SHORTCUTS; it installs VS 2012 shortcuts for VS 2013.

To fix it, edit the shortcuts. Rename them from 2012 to 2013, and change '11' to '12' in the path to vcvarsall.

See this microsoft social post.


I had same problem with Visual Studio 2010 on Windows XP. Just remove all constructions:

> nul 2>&1

from files:

\Microsoft Visual Studio 10.0\VC\bin\vcvars32.bat
\Microsoft Visual Studio 10.0\Common7\Tools\VCVarsQueryRegistry.bat

A simple solution to solve this issue both in vs developer command prompt and cmd is to add the following line

C:\Windows\System32

into the system path as follows:

My Pc-->properties-->Advanced-->Environment variables-->system variables hope it solves the issue.


My problem was a little bit different. As mentioned by @kzfabi - a registry is made to get details of the installed VS version. So the user executing the developer command line tools exe needs admin access as well as registry editing rights. In controlled environment set up by companies you may not have these rights and cause this error.

참고URL : https://stackoverflow.com/questions/3461275/vs2010-command-prompt-gives-error-cannot-determine-the-location-of-the-vs-commo

반응형