Skip to content
Heath Stewart edited this page Jan 30, 2019 · 9 revisions

vswhere.exe is a single-file, native executable you can download or redistribute with your build and deployment environments to locate Visual Studio or other products installed with the new installer for Visual Studio 2017.

By default it will find all complete and launchable (i.e. may have errors but otherwise usable) instances of Visual Studio and return all basic properties in plain text. There are several options to using this program to dictate which products to search, what workloads or components are required, what versions you want, and even the output format. Run the following command to see usage.

vswhere -?

The program can emit localized text to the console using Unicode, but redirecting to a file or piping to another program may require special handling. See our tips on encoding for more detail.

Read our FAQ for more information.

Installing

Starting with Visual Studio 15.2 (26418.1 Preview) vswhere.exe is installed in %ProgramFiles(x86)%\Microsoft Visual Studio\Installer (use %ProgramFiles% in a 32-bit program prior to Windows 10). This is a fixed location that will be maintained.

You can also download vswhere.exe from our releases page and redistribute it, or you can install it using a number of other options. This may be helpful when you cannot rely on Visual Studio being installed to determine its location or want to support older versions including RTM.

Examples

If you wanted to find MSBuild - now installed under the Visual Studio 2017 and newer installation root - you could script a command like the following to run the latest version of MSBuild installed. This example uses the new -find parameter in our latest release that searches selected instances for matching file name patterns. You can tailor what instances you select with parameters like -version or -prerelease to find specific versions you support, optionally including prereleases.

@echo off
setlocal enabledelayedexpansion

for /f "usebackq tokens=*" %%i in (`vswhere -latest -requires Microsoft.Component.MSBuild -find MSBuild\**\Bin\MSBuild.exe`) do (
  "%%i" %*
  exit /b !errorlevel!
)

New with version 1.0.50 you can also include Visual Studio 2010 and newer to get the installationPath. You will not be able to get as much information as for Visual Studio 2017 and newer.

You could, for example, find and launch devenv.exe for VS2010 or newer even if you don't have Visual Studio 2017 or newer installed.

$path = vswhere -legacy -latest -property installationPath
if (test-path "$path\Common7\IDE\devenv.exe") {
  & "$path\Common7\IDE\devenv.exe" $args
}

You can find more examples in our wiki.

Related

We have a number of related projects designed for certain use-cases and that also serve as an example of how to use both the native and managed query APIs.

  • Samples Samples in various programming languages that demonstrates how developers can use the new Visual Studio setup query API.
  • VSIXBootstrapper An installer that can be chained with other packages to locate the latest VSIXInstaller.exe to use for installing VSIX extensions
  • VSSetup.PowerShell PowerShell module to interact with Visual Studio Setup