Search notes:

vswhere.exe

vshwere.exe is the Visual Studio Locator.
vswhere.exe can be used to determine the root installation directory of Visual Studio, which is pointed at with the Visual Studio environment variable %VSINSTALLIDR% if the respective batch files were run.
Starting with Visual Studio 15.2, vswhere.exe is promised to be located under %programfiles(x86)%\Microsoft Visual Studio\Installer after installing Visual Studio (%ProgramFiles% in a 32 bit environment prior to Windows 10).

Program options

Selection

-all Finds all instances even if they are incomplete and may not launch.
-prerelease Also searches prereleases. By default, only releases are searched.
-products arg One or more product IDs to find. Defaults to Community, Professional, and Enterprise. * by itself searches all installed product instances. See https://aka.ms/vs/workloads for a list of product IDs.
-requires arg One or more workload or component IDs required when finding instances. All specified IDs must be installed unless -requiresAny is specified. See https://aka.ms/vs/workloads for a list of workload and component IDs.
-requiresAny Find instances with any one or more workload or components IDs passed to -requires.
-version arg A version range (with include/exclude semantics) for instances to find. Example: [15.0,16.0) will find versions 15.*.
-latest Return only the newest version and last installed.
-legacy Also searches Visual Studio 2015 and older products. Information is limited. This option cannot be used with either -products or -requires.
-path arg Gets the instance for the current path. Not compatible with any other selection option.

Output

-sort Sorts the instances from newest version and last installed to oldest. When used with "find", first instances are sorted then files are sorted lexigraphically.
-format arg Return information in the indicated format which is one of json, text, value or xml.
-property arg The name of a property to return. Defaults to "value" format. Use delimiters ".", "/", or "_" to separate object and property names. Example: "properties.nickname" will return the "nickname" property under "properties".
-find arg Returns matching file paths under the installation path. Defaults to "value" format. Supported patterns: ? (any one character except \), * (zero or more characters except \), ** (searches current directory and subdirectories for the remaining search pattern)
-nologo Do not show logo information. (Only the text format shows a format).
-utf8 Use UTF-8 encoding (recommended for JSON).
-?, -h or -help Prints a summary of program options

Example

The following invocation shows the root installation path in cmd.exe:
C:\> "%programfiles(x86)%\Microsoft Visual Studio\Installer\vswhere" -latest -property installationPath
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community
Find instances where a given component id is installed in PowerShell:
PS C:\> & 'C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe' -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath

See also

The PowerShell command noun vsSetupInstance.
C:\Program Files (x86)\Microsoft Visual Studio\Installer

Links

The source code of vswhere.exe is open source and hosted on Github.

Index