The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Win32::MachineInfo - Basic Windows NT/2000/XP OS and Hardware Info

SYNOPSIS

    use Win32::MachineInfo;

    my $host = shift || "";
    if (Win32::MachineInfo::GetMachineInfo($host, \%info)) {
        for $key (sort keys %info) {
            print "$key=", $info{$key}, "\n";
        }
    } else {
        print "Error: $^E\n";
    }

DESCRIPTION

Win32::MachineInfo is a module that retrieves basic OS, CPU, Memory, and Video information from a remote Windows NT/2000/XP machine. It uses Win32::TieRegistry to retrieve the information, which it returns as a hash structure.

FUNCTIONS

Win32::MachineInfo::GetMachineInfo($host, \%info);

where $host is the target machine and %info the hash that will contain the collected information if the function executes successfully. $host can be "HOST1", "\\\\HOST1", or "192.168.0.1". The function will return true if it completes successfully, false otherwise. If the function fails, it will probably be because it cannot connect to the remote machine's registry; the error will available through Win32::GetLastError.

The following fields are returned in %info:

$info{'computer_name'}
$info{'processor_vendor'}
$info{'processor_name'}
$info{'processor_speed'}
$info{'memory'}
$info{'system_bios_date'}
$info{'system_bios_version'}
$info{'video_bios_date'}
$info{'video_bios_version'}
$info{'video_adapter'}
$info{'display_resolution'}
$info{'refresh_rate'}
$info{'osversion'}
$info{'service_pack'}
$info{'system_root'}
$info{'install_date'}
$info{'install_time'}
$info{'registered_owner'}
$info{'registered_organization'}

EXAMPLES

Collecting OS Information from a Number of Machines

    use Win32::MachineInfo;

    @fields = qw/computer_name osversion display_resolution/;
    print join(",", @fields), "\n";
    while (<DATA>) {
        chomp;
        Win32::MachineInfo::GetMachineInfo($_, \%info);
        print join ",", @info{@fields};
        print "\n";
    }

    __DATA__
    HOST1
    HOST2
    HOST3

AUTHOR

James Macfarlane, <jmacfarla@cpan.org>

SEE ALSO

Win32::TieRegistry

Paul Popour's SRVCPUMEM.PL script was an inspiration and I am indebted to him for the formula that calculates memory from the value of the ".Translated" key.

I found the following sites helpful in compiling the translation tables that determine the 'processor_name' field from the processor_vendor and processor_identifier fields:

  • www.paradicesoftware.com/specs/cpuid/cpuid.htm

  • grafi.ii.pw.edu.pl/gbm/x86/cpuid.html

  • www.microflextech.com/support/intel/intel.htm