in reply to Determine exact OS of remote win32 server

I'd use Win32::TieRegistry.

#!/perl/bin/perl use strict; use warnings; use Win32::TieRegistry; my $host = shift || ''; my $hklm = $Registry->Connect($host, "HKEY_LOCAL_MACHINE", { Access => + 'KEY_READ' } ) or die $^E; my $info = $hklm->{"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion"}; my $ver = $info->{"CurrentVersion"}; my $sp = $info->{"CSDVersion"}; my $os = $hklm->{"SYSTEM\\CurrentControlSet\\Control\\ProductOptions\\ +ProductType"}; print "Remote OS: $os, Version: $ver, $sp\n";

NOTE: This will not work for Win9x or WinME.

Update: You could also use Win32::MachineInfo.

Replies are listed 'Best First'.
Re: (2) Determine exact OS of remote win32 server
by blackadder (Hermit) on Aug 18, 2003 at 20:38 UTC
    Thanks for this,....I ran this bit of code on my test pc which is an XP and I got this in return
    Remote OS: WinNT, Version: 5.1, Service Pack 1
    So I take it that version:5.1 means Windows XP!. Athough I won't be interested in XP once I run the script on the LAN. But I thought that the output be more specific than this...Anyway, I will only find out tomorrow.....Good night and God bless...
Re: Re: Determine exact OS of remote win32 server
by blackadder (Hermit) on Aug 21, 2003 at 12:33 UTC
    Win32::MachineInfo....Now thats a baby. Thanks a lot for this one.

    Cheers.