Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Determine the Windows OS Running

by slojuggler (Beadle)
on Nov 29, 2001 at 00:11 UTC ( [id://128162]=perlquestion: print w/replies, xml ) Need Help??

slojuggler has asked for the wisdom of the Perl Monks concerning the following question:

Without using Microsoft's gettype.exe, is there a quick-and-dirty Perlish way of determining whether the system running a script is Win2k Pro, Win2k Server, WinNT 4 Workstation, WinNT 4 Server? If not, could somebody point me into the right direction, or could point me to other alternatives aside from gettype.exe? Thanks.

Replies are listed 'Best First'.
Re: Determine the Windows OS Running
by $code or die (Deacon) on Nov 29, 2001 at 00:57 UTC
Re: Determine the Windows OS Running
by jlongino (Parson) on Nov 29, 2001 at 01:01 UTC
    slojuggler I did quite a bit of research on this recently so you may find something useful from Windows Version Detection. The best method would be to expand on Re: Re: Re: Re: Windows Version Detection by filling out the rest of the chart and put some additional logic as well. I stopped once I had arrived at what I needed but it looks like you need more.

    --Jim

    Update: It seems I got much of the info piecing together web searches for getosversion and VB snippets from MSDN developer pages. HTH.

Re: Determine the Windows OS Running
by Rich36 (Chaplain) on Nov 29, 2001 at 00:24 UTC
    From the camel...
    You can use $^0, which is a Perl special variable that holds the OS name.
    Or....
    Use the module Config.pm and use the variable $Config{osname}
    Rich36
    There's more than one way to screw it up...

      I'm not sure but AFAIK $^O will be 'MSWin32' for all Windows OSes. So it doesn't help.

      Config.pm should contain information about computer where Perl was built. In most cases for Win32 Perl it is some build server at ActiveState. So it doesn't help also.

        It appears you are correct...
        I got "MSWin32" as a value for both $^O and $Config{osname} running on NT, so my prior comment should be stricken/ignored in the context of this question.
        I should really test before I post unless I know for sure what I'm talking about...
        /me --
        Rich36
        There's more than one way to screw it up...

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://128162]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (6)
As of 2024-03-28 11:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found