แก้ไข

แชร์ผ่าน


Tools for detecting and managing Visual Studio instances

There are several tools that you can use to detect and manage Visual Studio installations on client machines.

Detecting existing Visual Studio instances

The following tools and utilities will help you detect and manage installed Visual Studio instances on client machines:

  • vswhere: an executable built into Visual Studio or available for separate distribution that helps you find the location of all Visual Studio instances on a particular machine.
  • VSSetup.PowerShell: PowerShell scripts that use the Setup Configuration API to identify installed instances of Visual Studio.
  • VS-Setup-Samples: C# and C++ samples that demonstrate how to use the Setup Configuration API to query an existing installation.
  • Windows Management Instrumentation (WMI): Visual Studio instance information can be queried through the Visual Studio class MSFT_VSInstance.
  • The Setup Configuration API provides interfaces for developers who want to build their own utilities for interrogating Visual Studio instances.
  • Microsoft Endpoint Configuration Manager software inventory: can be used to collect information about Visual Studio instances on client devices.

Using vswhere.exe

vswhere.exe is automatically included in Visual Studio 2017 and later, or you can download it from the vswhere releases page. Use vswhere -? to get help information about the tool. For example, this command shows all releases of Visual Studio, including earlier versions of the product and prereleases, and outputs the results in JSON format:

C:\Program Files (x86)\Microsoft Visual Studio\Installer>vswhere.exe -legacy -prerelease -format json

Using Windows Management Instrumentation (WMI)

If the Visual Studio Client Detector Utility is installed on the machine, then you can query for Visual Studio instance information using WMI. The Visual Studio Client Detector Utility is installed by default with every Visual Studio 2017, Visual Studio 2019, and Visual Studio 2022 update that was released on or after May 12, 2020. It is also available on the Microsoft Update Catalog if you want to install it independently. For an example of how to use the utility to return Visual Studio instance information, open up PowerShell as an administrator on the client machine, and type in the following command:

Get-CimInstance MSFT_VSInstance -Namespace root/cimv2/vs

Using Microsoft Endpoint Configuration Manager

Microsoft Endpoint Configuration Manager software inventory capabilities can be used to query and collect information about Visual Studio instances on client devices. For example, the following query will return the display name, version, and the device name Visual Studio is installed on for all installed Visual Studio 2017, 2019, and 2022 instances:

select distinct SMS_G_System_COMPUTER_SYSTEM.Name, SMS_G_System_ADD_REMOVE_PROGRAMS.DisplayName, SMS_G_System_ADD_REMOVE_PROGRAMS.Version from SMS_R_System inner join SMS_G_System_COMPUTER_SYSTEM on SMS_G_System_COMPUTER_SYSTEM.ResourceID = SMS_R_System.ResourceId inner join SMS_G_System_ADD_REMOVE_PROGRAMS on SMS_G_System_ADD_REMOVE_PROGRAMS.ResourceID = SMS_R_System.ResourceId where SMS_G_System_ADD_REMOVE_PROGRAMS.DisplayName like "Visual Studio %[a-z]% 201[7,9]" or SMS_G_System_ADD_REMOVE_PROGRAMS.DisplayName like "Visual Studio %[a-z]% 2022"

Editing the registry for a Visual Studio instance

In Visual Studio, registry settings are stored in a private location, which enables multiple side-by-side instances of the same version of Visual Studio on the same machine.

As these entries are not stored in the global registry, there are special instructions for using the Registry Editor to make changes to registry settings:

  1. If you have an open instance of Visual Studio, close it.

  2. Start regedit.exe.

  3. Select the HKEY_LOCAL_MACHINE node.

  4. From the Regedit main menu, select File > Load Hive... and then select the private registry file, which is stored in the AppData\Local folder. For example:

    %localappdata%\Microsoft\VisualStudio\<config>\privateregistry.bin
    

    Note

    <config> corresponds to the instance of Visual Studio that you would like to browse.

You will be prompted to provide a hive name, which becomes the name of your isolated hive. After you do so, you should be able to browse the registry under the isolated hive that you created.

Important

Before you start Visual Studio again, you must unload the isolated hive that you created. To do this, select File > Unload Hive from the Regedit main menu. (If you don't do this, then the file remains locked and Visual Studio will not be able to start.)

Support or troubleshooting

Sometimes, things can go wrong. If your Visual Studio installation fails, see Troubleshoot Visual Studio installation and upgrade issues for step-by-step guidance.

Here are a few more support options:

  • We offer an installation chat (English only) support option for installation-related issues.
  • Report product issues to us via the Report a Problem tool that appears both in the Visual Studio Installer and in the Visual Studio IDE. If you're an IT Administrator and don't have Visual Studio installed, you can submit IT Admin feedback here.
  • Suggest a feature, track product issues, and find answers in the Visual Studio Developer Community.