in reply to Get version of installed OS

Hi All,
I am trying to see if the Windows version I am using is newer than Windows 7 or Windows Server 2008 R2 (minimum requirements). I googled a bit and run into your post. Here is my question, I am running on Windows 10 machine and these lines:

print ("(\$ENV{\"OS\"}: " . ($ENV{"OS"}) . "\n"); use Win32; print "GetOSName: " . Win32::GetOSName() . "\n"; use Config; print "$Config{osname}\n"; print "$Config{archname}\n"; print "$Config{osvers}\n"; my ($name, $major, $minor, $build, $id) = Win32::GetOSVersion(); my %versions = ( 0 => {'' => {'' => "Win32s"}}, 1 => { 4 => { 0 => "Windows 95", 10 => "Windows 98", 90 => "Windows Me" } }, 2 => { 3 => {51 => "Windows NT 3.51"}, 4 => {0 => "Windows NT 4"}, 5 => { 0 => "Windows 2000", 1 => "Windows XP", 2 => "Windows Server 2003" }, 6 => { 0 => "Windows Vista or Server 2008", 1 => "Windows 7" } }, ); print "version: " . $id . ", " . $major . "," . $minor . "\n";
yields me:
($ENV{"OS"}: Windows_NT GetOSName: Win2003 MSWin32 MSWin32-x86-multi-thread 4.0 version: 2, 6,2
My questions are:
1) How can I see it is windows 10? Why do I receive "Windows_NT" and "Windows2003" in my first two lines?
2) @marto why do I get the version to be 4.0?
3) @GrandFather, I looked into the link you posted http://search.cpan.org/~jdb/Win32-0.52/Win32.pm, but all I see there is a table of:
OS ID MAJOR MINOR Win32s 0 - - Windows 95 1 4 0 Windows 98 1 4 10 Windows Me 1 4 90 Windows NT 3.51 2 3 51 Windows NT 4 2 4 0 Windows 2000 2 5 0 Windows XP 2 5 1 Windows Server 2003 2 5 2 Windows Server 2003 R2 2 5 2 Windows Home Server 2 5 2 Windows Vista 2 6 0 Windows Server 2008 2 6 0 Windows 7 2 6 1 Windows Server 2008 R2 2 6 1 Windows 8 2 6 2 Windows Server 2012 2 6 2
Where is Windows 10, 2016 and other which are newer (regular/server) from the requirement I wrote?

Replies are listed 'Best First'.
Re: Get version of installed OS
by Tux (Canon) on Feb 26, 2018 at 17:08 UTC

    Might System::Info help?

    C:\> cpan System::Info C:\> perl -MSystem::Info -wE"say System::Info->new->os" MSWin32 - Win7 Professional (64-bit) SP1

    Enjoy, Have FUN! H.Merijn
      I found a solution, I will use:
      my ($name, $major, $minor, $build, $id) = Win32::GetOSVersion();
      and check the values are greater than or equal to id - 2, $major - 6, $minor - 1. I guess higher version of Windows got the 262 value