Scott,

You can get the Win32_BIOS object directly from the WMI object. The
appended script demonstrates (though is lazy in other respects - I can't
vouch for the assumption of only one instance of Win32_BIOS).

Also, the Win32_ComputerSystem attributes such as "Manufacturer" and
"Model" may be of interest.

Given an idea of what class names you're looking for, WBEMTEST.EXE can help
to sort through them and their attributes.

Tom Wyant
#! perl -w

use strict;
use Win32::OLE qw{in};

my $server = shift @ARGV || '.';

my $wmi = Win32::OLE->GetObject ("winmgmts://$server/root/cimv2") or
    die "Error - Failed to get WMI object\n",
        Win32::OLE->LastError ();

my ($system) = (in $wmi->InstancesOf ('Win32_ComputerSystem'))
    or die "Error - Failed to get Win32_ComputerSystem object\n",
        Win32::OLE->LastError ();
my ($bios) = (in $wmi->InstancesOf ('Win32_BIOS'))
    or die "Error - Failed to get Win32_BIOS object\n",
        Win32::OLE->LastError ();

print <<"-- computer info --";

System \\$server:
    Manufacturer: @{[$system->{Manufacturer} || '<Unavailable>']}
           Model: @{[$system->{Model} || '<Unavailable>']}
   Serial number: @{[$bios->{SerialNumber} || '<Unavailable>']}

-- computer info --





"Scott Campbell" <[EMAIL PROTECTED]>@listserv.ActiveState.com on 08/20/2002
08:20:14 AM

Sent by:    [EMAIL PROTECTED]


To:    <[EMAIL PROTECTED]>,
       <[EMAIL PROTECTED]>
cc:
Subject:    RE: BIOS Access


This can be done through WMI (Windows Management Instrumentation).  It
comes installed by default on Windows 2000, XP, and 98 Second Edition.
For other OS's, you may download the WMI package from Microsoft.

You access this information through the Win32::OLE module.
Below is a snippet that should work for you:
------------------------------------------------------------------------
--
use Win32::OLE qw(in with);

$server='YOUR_COMPUTER_NAME_HERE';

my $WMIServices =Win32::OLE->GetObject(
"winmgmts:{impersonationLevel=impersonate,(security)}//$server" );

$WMI = Win32::OLE->new('WbemScripting.SWbemLocator');
$Services = $WMI->ConnectServer($server);

my $bios_set = $Services->InstancesOf("Win32_BIOS");
foreach my $bios (in($bios_set)) {
      print "$bios->{'Caption'}'\n";
      print "$bios->{'BuildNumber'}\n";
      print "$bios->{'CurrentLanguage'}\n";
      print "$bios->{'Description'}\n";
      print "$bios->{'InstallDate'}\n";
      print "$bios->{'Name'}\n";
      print "$bios->{'Manufacturer'}\n";
      print "$bios->{'PrimaryBIOS'}\n";
      print "$bios->{'ReleaseDate'}\n";
      print "$bios->{'SerialNumber'}\n";
      print "$bios->{'SMBIOSBIOSVersion'}\n";
      print "$bios->{'SMBIOSMajorVersion'}\n";
      print "$bios->{'SMBIOSMinorVersion'}\n";
      print "$bios->{'SMBIOSPresent'}\n";
      print "$bios->{'SoftwareElementID'}\n";
      print "$bios->{'Status'}\n";
      print "$bios->{'Version'}\n";
}
------------------------------------------------------------------------
--
Make sure you are running as an admin account to get this info.
Further info on this can be found on the msdn site of Microsoft.
These WMI groups (ie: Win32_BIOS) are called classes.  You may look them
up to see what everything means.
This will compile fine with PerlApp from the PDK of ActiveState.

Note, this information is not gauranteed to be present.  It's only there
if the OS can access it, and it's available via the hardware.

Scott Campbell
Senior Software Developer
Somix Technologies
(207) 324-8805
http://www.somix.com

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]] On Behalf Of
[EMAIL PROTECTED]
Sent: Monday, August 19, 2002 9:23 PM
To: [EMAIL PROTECTED]
Subject: BIOS Access

Does anyone know of anyway to access the information stored in the BIOS
from Perl?  I would like to access the Serial Number and Model Type of a
machine from NT/2K/XP, _without_ using an external program.  I have
looked
around but have been unable to find any module to help with this task.
There is also no registry key that contains the information I am looking
for.  I have other ways I can get this information, but they all require
a
3rd party app to pull this information, and then have a perl script
parse
through this.  I am trying to avoid this, and having perl installed on
the
workstation, as I would like to compile this using PDK and only want to
have one executable to manage.

Any ideas would be greatly appreciated.

Thanks.

Len.


_______________________________________________
Perl-Win32-Admin mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



_______________________________________________
Perl-Win32-Admin mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



_______________________________________________
Perl-Win32-Admin mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to