Determining Windows Version

From IronPython Cookbook

This is IronPython translation of analogous C# code

import clr
from System.Environment import OSVersion
from System.PlatformID import Win32Windows, Win32NT 

operatingSystem = 'Unknown'

major = OSVersion.Version.Major
minor = OSVersion.Version.Minor

if OSVersion.Platform == Win32Windows:

    if minor == 0:
        operatingSystem = 'Windows 95'
    elif minor == 10:
        operatingSystem = 'Windows 98'
    elif minor == 90:
        operatingSystem = 'Windows Me'

elif OSVersion.Platform == Win32NT:

    if major == 3:
       operatingSystem = 'Windows NT 3.52'
    elif major == 4:
        operatingSystem = 'Windows NT 4.0'
    elif major == 5: 
        if minor == 0:
            operatingSystem = 'Windows 2000'
        else:
            operatingSystem = 'Windows XP'
    elif major == 6: 
        operatingSystem = 'Windows Vista'


if __name__ == '__main__':
    print operatingSystem


Back to Contents.

TOOLBOX
LANGUAGES