[visual-studio] How can I check what version/edition of Visual Studio is installed programmatically?

I could read registry HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\10.0. However, it doesn't give me any information about the edition of it - Professional/Ultimate or whatever.

How can I get the information with programmatically (preferably python)?

enter image description here

This question is related to visual-studio registry

The answer is


if somebody needs C# example then:

var registry = Registry.ClassesRoot;
var subKeyNames = registry.GetSubKeyNames();
var regex = new Regex(@"^VisualStudio\.edmx\.(\d+)\.(\d+)$");
foreach (var subKeyName in subKeyNames)
{
    var match = regex.Match(subKeyName);
    if (match.Success)
        Console.WriteLine("V" + match.Groups[1].Value + "." + match.Groups[2].Value);
}

In Visual Studio, the Tab 'Help'-> 'About Microsoft Visual Studio' should give you the desired infos.


For anyone stumbling on this question, here is the answer if you are doing C++: You can check in your cpp code for vs version like the example bellow which links against a library based on vs version being 2015 or higher:

#if (_MSC_VER > 1800)
#pragma comment (lib, "legacy_stdio_definitions.lib")
#endif

This is done at link time and no extra run-time cost.


Run the path in cmd C:\Program Files (x86)\Microsoft Visual Studio\Installer>vswhere.exe


Its not very subtle, but there is a folder in the install location that carries the installed version name.

eg I've got:

C:\Program Files\Microsoft Visual Studio 9.0\Microsoft Visual Studio 2008 Standard Edition - ENU

and

C:\Program Files\Microsoft Visual Studio 10.0\Microsoft Visual Studio 2010 Professional - ENU

You could find the install location from the registry keys you listed above.

Alternatively this will be in the registry at a number of places, eg:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\9.0\Setup\Microsoft Visual Studio 2008 Standard Edition - ENU

There are loads of values and keys with the string in, you can find them by looking for "Microsoft Visual Studio 2010" in the Regedit>Edit>Find function.

You'd just need to pick the one you want and do a little bit of string matching.


Put this code somewhere in your C++ project:

#ifdef _DEBUG
TCHAR version[50];
sprintf(&version[0], "Version = %d", _MSC_VER);
MessageBox(NULL, (LPCTSTR)szMsg, "Visual Studio", MB_OK | MB_ICONINFORMATION);
#endif

Note that _MSC_VER symbol is Microsoft specific. Here you can find a list of Visual Studio versions with the value for _MSC_VER for each version.


Open the installed visual studio software and click the Help menu select the About Microsoft Visual studio--> Get the visual studio Version


An updated answer to this question would be the following :

"C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe" -latest -property productId

Resolves to 2019

"C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe" -latest -property catalog_productLineVersion

Resolves to Microsoft.VisualStudio.Product.Professional


You can get the VS product version by running the following command.

"C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe" -property catalog_productDisplayVersion

All the information in this thread is now out of date with the recent release of vswhere. Download that and use it.