58

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

10 Answers 10

43

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

1
  • 9
    thanks for the answer, but I forgot mention 'programmatically'.
    – prosseek
    Feb 23, 2011 at 10:17
10

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
8

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

6

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);
}
1
  • 2
    This will work only if Entity Data Model (EDMX) is installed for all installed Visual Studio versions. Dec 26, 2016 at 12:56
5

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

1
  • And if I have multiple versions of VisualStudio installed ( 2015, 2017, 2019 ) is there a way to get them all from the command line ?
    – Epligam
    May 4, 2021 at 9:52
3

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.

3

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.

2

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

1
  • 1
    Vice versa, though. Aug 11, 2022 at 15:13
1

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

3
  • Comment is true. -legacy flag doesn't help if you need to know edition and version as in main question. I have installed 2015 and 2107. But vswhere shows that I have 10.0, 11.0, 12.0, 14.0(2015) and 2017. So it almost usless for old Studios.
    – vik_78
    Jun 1, 2018 at 16:42
  • Interesting, I'm correctly detecting only VS2015 with vswhere. Did you previously have the old IDEs on your machine?
    – johnwbyrd
    Jun 2, 2018 at 0:39
  • I have all MS Management Studios installed. They have shell from VS. That's could be the reason
    – vik_78
    Jun 3, 2018 at 14:06
0

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.