[python-win32] GetWindowsVersion on Longhorn

Mark Hammond skippy.hammond at gmail.com
Fri Feb 6 02:15:46 CET 2009


On 23/01/2009 11:40 AM, Matt Herbert (matherbe) wrote:
> Hey all,
>
> Just wondering if there is a way to differentiate Windows Server 2008
> from Windows Vista? All the normal methods I would use aren't cutting
> it. For instance, sys.getwindowsversion() and platform.uname() are
> returning exactly the same thing for Vista and Windows 2008.

This was a while ago now, but I also just needed to determine this 
information.

If you ask win32api to give you an OSVERSIONINFOEX tuple, you can get 
the 'wProductType' field.  eg, on Vista:

 >>> win32api.GetVersionEx(1)
(6, 0, 6001, 2, 'Service Pack 1', 1, 0, 256, 1, 30)

on 2008:

(6, 0, 6001, 2, 'Service Pack 1', 1, 0, 274, 2, 30)

The 2nd-last item is wProductType and defined as:
VER_NT_DOMAIN_CONTROLLER=0x0000002
VER_NT_SERVER=0x0000003
VER_NT_WORKSTATION=0x0000001

Vista reports itself as a 'workstation', where 2008 will report itself 
as a server or a DC (and I did indeed run the above test on a 2008 DC)

For-the-archives ly,

Mark



More information about the python-win32 mailing list