#!/usr/bin/env perl use strict; use v5.18; use utf8; use warnings; use Carp qw/carp croak/; =head1 DESCRIPTION Find the major Windows version from the commandline "ver" command. =cut # ------------------------------------------------------- # # Example Windows 11 version string (bought the machine # with Windows 10 loaded on it): # Microsoft Windows [Version 10.0.26100.4349] # ------------------------------------------------------- # sub findVer { my ( $which , $verstr ); $verstr = `ver`; chomp $verstr; $verstr =~s{\A\n}{}; $verstr =~m'\[Version\s (\d+) [.]'x; carp( qq/Couldn't get version from string "$verstr"/ ) unless $1; $which = $1; return $which; } say findVer(); __END__ #### --- a/t/02-Win32-Netsh-Wlan.t 2015-11-17 16:07:55.000000000 -0500 +++ b/t/02-Win32-Netsh-Wlan.t 2025-06-18 14:52:56.388437700 -0400 @@ -26,36 +26,61 @@ ); } use_ok(qq{Win32::Netsh::Wlan}, (qw(:all))); } +##--------------------------------------- +## Find Windows Version + +# ------------------------------------------------------- # +# Example Windows 11? or 10? version string: +# Microsoft Windows [Version 10.0.26100.4349] +# ------------------------------------------------------- # +sub findVer +{ + my ( $which , $verstr ); + $verstr = `ver`; + chomp $verstr; + $verstr =~s{\A\n}{}; + $verstr =~m'\[Version\s (\d+) [.]'x; + carp( qq/Couldn't get Windows version from string "$verstr"/ ) unless $1; + $which = $1; + # say "VERSION: " . $which; + return $which; +} + +my $generation = findVer(); ##--------------------------------------- ## List of profiles to use for testing ##--------------------------------------- my @test_profiles = ( { filename => qq{win32-netsh-wlan-single.xml}, info => { name => qq{Win32-Netsh-Wlan-Single}, auth => qq{Open}, cipher => qq{None}, - interface => qq{Wireless Network Connection}, + interface => ( $generation >= 10 ? + qq{Wi-Fi} + : qq{Wireless Network Connection} ), mode => qq{automatical}, net_type => qq{Infrastructure}, radio => qq{[ Any Radio Type ]}, ssid => [qq{SSID-Single}], }, }, { filename => qq{win32-netsh-wlan-dual.xml}, info => { name => qq{Win32-Netsh-Wlan-Dual}, auth => qq{Open}, cipher => qq{None}, - interface => qq{Wireless Network Connection}, + interface => ( $generation >= 10 ? + qq{Wi-Fi} + : qq{Wireless Network Connection} ), mode => qq{automatical}, net_type => qq{Infrastructure}, radio => qq{[ Any Radio Type ]}, ssid => [ qq{SSID-Dual-01}, qq{SSID-Dual-02}