With previous versions of VS you could query the registry to determine the installation directory for VS:
HKLM\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\14.0
However, this doesn't seem to work with the VS2017 RC. We have scripts that detect the latest installed VS and then do "the right thing", and so far I'm having issues plugging VS2017 into those systems.
Does anyone know how to programmatically determine the installation location for VS2017?
KindDragon's solution didn't quite work for me due to batch's "delayed expansion" "feature". (WAT)
Here is my code, compatible with VS 2017 15.2 (for the vswhere.exe installation)
Especially note usage of SETLOCAL EnableDelayedExpansion and !InstallDir!
May I recommend my package get-vs2017-path it uses only built-in Windows tools (and although it's built as an
NPM
package, it has no dependencies, and the tools folder works standalone)Visual Studio 2017 supports no-registry, side-by-side installations of all SKUs (Enterprise, Professional and Community).
MSI installlers can query via APIs described here: https://blogs.msdn.microsoft.com/heaths/2016/09/15/changes-to-visual-studio-15-setup/
Examples are here:
You can use this PowerShell snippet for finding the VS2017 installation directory:
Well, vswhere.exe doesn't really supply more than the Visual Studio edition installation path. Here's my .profile file Interix snippet from 2008 doing the same with a minor update (shell script):
That's enumerating Visual Studio installations favouring the latest in registry key
Still working for Visual Studio 2017. Would be easy to translate to cmd syntax. To query the registry is simpler and doesn't require vswhere.exe in your path, thus favourable IMO.
Now finding the current Visual C++ instance and the SDKs is another task entirely. :D
Common output in case you wonder:
It's possible to query Visual studio installation path from registry, see following answer:
https://stackoverflow.com/a/48915860/2338477
You can either use batch itself and get it's output back to application or even simpler - use registry functions to query key value.
Limitations of this approach are described in answer.