I started out looking at $^O, but it: "Contains the name of the operating system that the current Perl binary was compiled for." (from Perl in a Nutshell). Besides the value returned in my particular test program under Win98 was "MSWin32" which is not nearly specific enough.
Then I looked through Learning Perl on Win32 Systems at the Win32::Registry modules, but there are too many inconsistencies between OS registry structures.
After much frustration with Win NT 4.0, I typed the DOS VER command from a DOS shell and thought "Hmm ..., this might work". Then I tested VER on Win95/98/2k machines and discovered that I could use them as well. So far I have the following snippet:
Since I don't have access to an NT 3.51 machine, I guessed at that one. I also need an example for Win ME as well but I can get that later at work.my $ver_str = `ver`; # Test strings # my $ver_str = 'Windows 98 [Version 4.10.1998]'; # my $ver_str = 'Microsoft Windows 2000 [Version 5.00.2195]'; # my $ver_str = 'Microsoft Windows 95. [Version 4.00.1111]'; ## guessed on this one ## my $ver_str = 'Windows NT Version 3.51'; # my $ver_str = 'Windows NT Version 4.0'; print "VER: $ver_str\n"; $_ = $ver_str; my $os_ver = "N/A"; $os_ver = 'win95' if m/( 95 | 95. )/; $os_ver = 'win98' if m/ 98 /; $os_ver = 'nt351' if m/ NT / && m/ 3.51/; $os_ver = 'nt40' if m/ NT / && m/ 4.0/; $os_ver = 'win2k' if m/ 2000 /; print "\$os_ver: $os_ver\n\n";
The problems that I see now are:
So if anyone here at the Monastery has any reasonable ideas or suggestions I love to ++ them for it. Thanks.
P.S., this is related to my node Small Project Definition.
"The reward of a thing well done, is to have to done it." -- Ralph Waldo Emerson
In reply to Windows Version Detection by jlongino
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |