Reputation: 190809
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)?
Upvotes: 64
Views: 340677
Reputation: 660
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 Microsoft.VisualStudio.Product.Professional
"C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe" -latest -property catalog_productLineVersion
Resolves to 2019
Upvotes: 4
Reputation: 394
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
Upvotes: 20
Reputation: 6607
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.
Upvotes: 0
Reputation: 59
Run the path in cmd C:\Program Files (x86)\Microsoft Visual Studio\Installer>vswhere.exe
Upvotes: 5
Reputation: 3758
All the information in this thread is now out of date with the recent release of vswhere. Download that and use it.
Upvotes: 1
Reputation: 7837
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);
}
Upvotes: 6
Reputation: 163
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.
Upvotes: 4
Reputation: 105
Open the installed visual studio software and click the Help menu select the About Microsoft Visual studio--> Get the visual studio Version
Upvotes: 8
Reputation: 41549
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.
Upvotes: 3
Reputation: 8150
In Visual Studio, the Tab 'Help'-> 'About Microsoft Visual Studio' should give you the desired infos.
Upvotes: 54