P0w3rK!d has asked for the wisdom of the Perl Monks concerning the following question:

Hello fellow monks,

Using

use Config; $PLATFORM = $Config{'osname'}; # and my @OS_VER = Win32::GetOSVersion;

'osname' is used to determine what flavor of OS I am on MSWin32, solaris, linux, etc. as I am working on every platform out there.

My question is: How do I differentiate between .NET Enterprise Server and Windows 2003 server when I get back verion 5.2 from Win32::GetOSVersion. (see chart)

Is there anything else out there I can use?

Thank you :)

-P0w3rK!d

        # Name                      'osname'    $ENV{'OS'}  Version     Build
        # ------------------------  --------    ----------  -------     -----
        # Windows NT4.0             MSWin32     Windows_NT  4.0         1381
        # Windows 2000 Server       MSWin32     Windows_NT  5.0         2195
        # Windows XP, XP Pro        MSWin32     Windows_NT  5.1         21##
        # .NET Enterprise Server    MSWin32     Windows_NT  5.2         36##
        # Windows 2003 Server       MSWin32     Windows_NT  5.2         37##

Replies are listed 'Best First'.
Re: How to determining if I am on .NET versus Windows 2003
by dragonchild (Archbishop) on Apr 04, 2003 at 17:49 UTC
    Is there a Win32::GetBuildVersion? Seems like that's the only difference ...

    ------
    We are the carpenters and bricklayers of the Information Age.

    Don't go borrowing trouble. For programmers, this means Worry only about what you need to implement.

    Please remember that I'm crufty and crochety. All opinions are purely mine and all code is untested, unless otherwise specified.

Re: How to determining if I am on .NET versus Windows 2003
by Mr. Muskrat (Canon) on Apr 04, 2003 at 17:50 UTC

    What does this print?

    use Win32; print Win32::GetOSName(),$/;

    Update: Hmm, looks like it doesn't differentiate between them yet... so you will need to check the build numbers.

      I think it works;)
      C:\>perl use Win32; local $\ = $/; print for Win32::GetOSName(),Win32->VERSION; __END__ Win2000 Service Pack 3 0.191 C:\>


      MJD says you can't just make shit up and expect the computer to know what you mean, retardo!
      I run a Win32 PPM repository for perl 5.6x+5.8x. I take requests.
      ** The Third rule of perl club is a statement of fact: pod is sexy.

        Yes, it works, sort of. If you have ActiveState Build 633 or later, Win32::GetOSName() is going to return "XP/.Net" for XP, .NET and Windows 2003.

      Windows .NET Enterprise Server:

      Windows version [2:5:2] unknown! at PERL2EXE_STORAGE/Win32.pm line 129

      Windows 2003 Server:

      Windows version [2:5:2] unknown! at PERL2EXE_STORAGE/Win32.pm line 129

      Thanks for your help. Do you know where the cutoff point for 2003 and .NET is? Are they 3600 and 3700, respectively??

      -P0w3rK!d

        I'm not sure. From the looks of it, neither is MS Operating System Properties.

        You might try running winver...

        1. Click Start | Run.
        2. In the Open box, type Winver.
        3. Click OK or press Enter.

        I haven't done much with Win32 in perl and others have already stated the whole 'can you get the build version' but from what was given, it seems we know the following:
        1. build versions are the only difference in the given chart
        2. .NET has 36## for build version
        3. 2003 has 37## for build version
        First, since I don't know what the variables are for Config, I do the following:
        foreach $i (keys %Config) { print "$i\n"; }
        Perhaps a set variable based on what the build version is?
        Example:
        $build_prefix = substr Win32::GetBuild, 0, 2; if ($build_prefix == '36') { # do something for .NET } elsif ($build_prefix == '37') { # do something for 2003 }
        Course, it'd be better if I knew for sure you could get the build version from Config or Win32, but it's a helping hand! I'm probably going to go look it up soon anyways just to know, hehe...

        EDIT: after looking back over this, it seems the above code/etc is a really kludgy way of doing it and I probably should've done my homework before posting. Bah, I say...it's 12:30 and I'm still at work!
Re: How to determining if I am on .NET versus Windows 2003
by TacoVendor (Pilgrim) on Apr 04, 2003 at 21:45 UTC
    The understanding I have about it all is that .NET was deemed confusing by the Microsoft Brass. All of the .NET product lines had their names changed to 2003.

    I don't know what the cutoff Build number was, but I would take a guess and say that it is not really what you are looking for. In short, same product - 2 names.
Re: How to determining if I am on .NET versus Windows 2003
by Necos (Friar) on Apr 05, 2003 at 10:31 UTC
    Hmmm... I recall there being a function in the Win32::AdminMisc module that would return all of the information about an OS, including the build number. Unfortunately, I'm pretty sure the module is no longer under development. However, I do believe the source is available from Dave Roth's website. You can always just recompile the source to match your perl distribution and use that (if I recall, it's one of those XS-based modules).

    I'm not sure if ActiveState has included a GetOSBuild-type function in the Win32 module (I still use 522 on my Windows machines) for the newer versions of their Perl. Also, a word of caution. The Win32::AdminMisc module was built before WinXP. So, some of the tricks Dave used to build the module may be broken in the newer include files (in MS VC++). However, it should be possible to backtrack and update the code dependencies if that's the case.

    Hope that helps some,

    Theodore Charles III
    Network Administrator
    Los Angeles Senior High
    email->secon_kun@hotmail.com
    perl -e "map{print++$_}split//,Mdbnr;"
Re: How to determining if I am on .NET versus Windows 2003
by bart (Canon) on Apr 06, 2003 at 10:28 UTC
    I can't help but wonder... If it's so damn hard to figure out the difference between the two, why do you even care?

    Knowing Microsoft, it could indeed be nothing more than a simple name change, like TacoVendor wrote. Perhaps progress in .NET didn't advance as swiftly as Microsoft had wanted, and they're lowering the expectations by going back to the old name. Who knows.

Re: How to determining if I am on .NET versus Windows 2003
by Anonymous Monk on Apr 05, 2003 at 22:09 UTC
    perldoc Win32::OLE + msdn-search->WMI
Re: How to determining if I am on .NET versus Windows 2003
by SteveTheRed (Sexton) on Apr 07, 2003 at 01:26 UTC
    Maybe this isn't very helpful, but if I type:

    c:\>ver
    I get:

    Microsoft Windows XP [Version 5.1.2600]
    Unfortunately, I only have access to XP Home Edition (yuk!) here, so I can't tell if this way of getting the os version is any different than the others.
Re: How to determining if I am on .NET versus Windows 2003
by czrdup (Acolyte) on Apr 07, 2003 at 04:24 UTC
    Here I am a day late and a dollar short and maybe I missed something, but couldn't you just do something with Win32::GetOSVersion()? It seems to return Build (as well as everything else you might need), but noone seems to have mentioned it.

    Perl Doc for lack of a better source at the moment.