bibble235
bibble235

Reputation: 818

How do I detect the version of visual studio installed with a python script

The make system uses python. The autobuilders it is 10 but in development it is 11.0. It would be good to do this dynamically.

Upvotes: 1

Views: 2841

Answers (1)

Thorsten Kranz
Thorsten Kranz

Reputation: 12765

Look at this How-To, then use this from the standard library to read the specific keys.

Try:

import _winreg

key = "SOFTWARE\Microsoft\VisualStudio\%s"

possible_versions = ["10.0", "11.0"]
installed_versions = []

for v in possible_versions:
    try:
        _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, key%v, 0, _winreg.KEY_ALL_ACCESS)
        installed_versions.append(v)
    except Exception, e:
        pass

print installed_versions

This gives me

['10.0']

Upvotes: 1

Related Questions