windowsvisual-studiovisual-studio-2017visual-studio-2017-build-tools

Visual Studio c++ build tools: VsDevCmd.bat / vcvarsall.bat fails to find some [unknown] paths and thus to run


I am having trouble setting up the 2017 VC++ build tools, both as standalone or installed with the VS community edition.

Specifically, everything seems installed ok, but calls to vcvarsall.bat do not work - python distutils complains:

ImportError: Building module some_module_name failed: ['distutils.errors.DistutilsPlatformError: Error executing cmd /u /c "C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Community\\VC\\Auxiliary\\Build\\vcvarsall.bat" x86_amd64 && set\n']
Process finished with exit code 1

when running vcvarsall.bat from cmd:

C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build>vcvarsall.bat x64
Das System kann den angegebenen Pfad nicht finden.
**********************************************************************
** Visual Studio 2017 Developer Command Prompt v15.9.27
** Copyright (c) 2017 Microsoft Corporation
**********************************************************************
Das System kann den angegebenen Pfad nicht finden.
Das System kann den angegebenen Pfad nicht finden.
[vcvarsall.bat] Environment initialized for: 'x64'

("Das System kann den angegebenen Pfad nicht finden." is German for "system cannot find the path provided")

Similar for VsDevCmd.bat:

C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\Tools>VsDevCmd.bat
Das System kann den angegebenen Pfad nicht finden.
**********************************************************************
** Visual Studio 2017 Developer Command Prompt v15.9.27
** Copyright (c) 2017 Microsoft Corporation
**********************************************************************
Das System kann den angegebenen Pfad nicht finden.
Das System kann den angegebenen Pfad nicht finden.
Das System kann den angegebenen Pfad nicht finden.

I could not get it to at least report which path cannot be found... Any ideas how to fix this?

Tried many reinstalls, also of different versions, (2019 - same, standalone 2017 build tools etc.)

Edit: I got full diagnostic output as suggested by @HansPassant; it is too long to paste here fully.

Note: Errors occur always after for /F ...
I found all directories listed in plaintext before the errors.
Only exception is the reg key at FEHLER: Der angegebene Registrierungsschlüssel bzw. Wert wurde nicht gefunden. ("Error: Did not find reg key or value") which indeed does not seem to exist.

>set __VSCMD_VER=

>for /F "tokens=1,2,* delims==+" %A in ('type "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\devenv.isolation.ini"') do (
if "3" GEQ "3"
 if /I "%A" == "SemanticVersion" (
if "3" GEQ "1"
 set "__VSCMD_VER=%B"
)
)
**Das System kann den angegebenen Pfad nicht finden.**


[...]

>for /F "tokens=1,2*" %i in ('reg query "HKLM\SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\Windows\v10.0" /v "InstallationFolder"') DO (if "%i" == "InstallationFolder" (SET WindowsSdkDir=%~k ) )
Das System kann den angegebenen Pfad nicht finden.

[...]

 if EXIST "C:\Program Files (x86)\Windows Kits\10\include\%i\um\winsdkver.h" (
set result=%i
 if "!result:~0,3!" == "10." (
set SDK=!result!
 if "!result!" == "" set findSDK=1
)
)
)
Das System kann den angegebenen Pfad nicht finden.

[...]

>for /F "tokens=1,2*" %i in ('reg query "HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows Kits\Installed Roots" /v "KitsRoot10"') DO (if "%i" == "KitsRoot10" (SET UniversalCRTSdkDir=%k ) )
Das System kann den angegebenen Pfad nicht finden.

[...]


>for /F %i IN ('dir "C:\Program Files (x86)\Windows Kits\10\include\" /b /ad-h /on') DO (
set result=%i
 if "!result:~0,3!" == "10." set CRT=!result!
 if "!result!" == "" set match=1
)
Das System kann den angegebenen Pfad nicht finden.

[...]

>for /F %a in ('dir "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\Tools\vsdevcmd\ext\*.bat" /b /a-d-h /on') do (call :call_script_helper ext\%a )
Das System kann den angegebenen Pfad nicht finden.

[...]


>for /F "tokens=1,2*" %i in ('reg query "HKLM\SOFTWARE\Microsoft\VisualStudio\VSPerf" /v "CollectionToolsDir"') DO (if "%i" == "CollectionToolsDir" (SET "__collection_tools=%k" ) )
Das System kann den angegebenen Pfad nicht finden.
FEHLER: Der angegebene Registrierungsschlüssel bzw. Wert wurde nicht gefunden.

[...]

>for /F %A in ('type "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\Microsoft.VCToolsVersion.default.txt"') do (set "__VCVARS_TOOLS_VERSION=%A" )
Das System kann den angegebenen Pfad nicht finden.

[...]

>for /F %A in ('type "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\Microsoft.VCRedistVersion.default.txt"') do (set "__VCVARS_REDIST_VERSION=%A" )
Das System kann den angegebenen Pfad nicht finden.



Solution

  • This seams to be a common issue for last months and there was a fix posted by Steven2105

    • Open the Registry Editor (Windows key and type regedit in the prompt)
    • Go to HKEY_CURRENT_USER\Software\Microsoft\Command Processor\AutoRun and clear the values.
    • If it exists in HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\AutoRun, delete it as well.

    So run regedit.exe and delete the mentioned values to repair cmd.