Python validation server version
I need to record the current Windows version in my python application for reporting purposes, but the built-in functions I've found so far cannot distinguish between client and server versions of Windows:
os.sys.getwindowsversion()
(6, 0, 6002, 2, 'Service Pack 2')
platform.release()
'Vista'
platform.win32_ver()
('Vista', '6.0.6002', 'SP2', 'Multiprocessor Free')
These functions return the same values on Windows Vista and Windows Server 2008 (because they have the same version number).
Is there a way to get the correct Windows version?
a source to share
You can use GetVersionEx Win32 API and check the value wProductType
for differentiation.
Check out Python package for Windows .
VER_NT_DOMAIN_CONTROLLER 0x0000002
A system is a domain controller and an operating system is Windows Server 2008, Windows Server 2003, or Windows 2000 Server.
VER_NT_SERVER 0x0000003
Operating system - Windows Server 2008, Windows Server 2003, or Windows 2000 Server.
Note that a server that is also a domain controller is reported as VER_NT_DOMAIN_CONTROLLER and not VER_NT_SERVER.
VER_NT_WORKSTATION 0x0000001
Operating system - Windows Vista, Windows XP Professional, Windows XP Home Edition or Windows 2000 Professional.
a source to share
Try to fetch it using WMI Win32_OperatingSystem
class ( ProductType
is 3
on server systems). Scriptomatic can generate Python code for this.
a source to share