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):
if [[ -n $PROCESSOR_ARCHITEW6432 || $PROCESSOR_ARCHITECTURE != "x86" ]]; then
hkeybase='HKLM\SOFTWARE\Wow6432Node\Microsoft\'
else
hkeybase='HKLM\SOFTWARE\Microsoft\'
fi
for vsver in "15.0" "14.0" "12.0" "11.0" "10.0" "9.0" "8.0"; do
_vsinstalldir=$(reg.exe query ${hkeybase}'VisualStudio\SxS\VS7' -v $vsver 2>/dev/null \
| sed -n 's|.*REG_SZ *\([ [:print:]]*\).*|\1|p' | sed 's|\\|/|g')
if [[ -n $_vsinstalldir ]]; then break; fi
done; unset vsver
That's enumerating Visual Studio installations favouring the latest in registry key
HKLM\SOFTWARE\Microsoft\VisualStudio\SxS\VS7
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:
C:/Program Files (x86)/Microsoft Visual Studio/2017/Enterprise/
Wow
nodes. They only exist in x64 systems to allow x86 applications to work. Have you checked theHKLM\SOFTWARE\Microsoft\VisualStudio\15.0\Setup
node? Anyway, the disk layout has changed a lot. Almost everything can be found in the `%PROGRAM FILES%\Microsoft Visual Studio 15.0` now – Ruth