Use this as a hack template till you get your head around it:
#!perl

# Simple Perl Script to illustrate use of WMI to gather system
information
# and display it in the same format at the Windows Management Console

use Win32::OLE qw(in with);
use Win32::Registry;

# Pick a host that you have the necessary rights to monitor

$host = "johnathlonxpm";

# Gather System Information

$WMI = Win32::OLE->new('WbemScripting.SWbemLocator') ||
 die "Cannot access WMI on local machine: ", Win32::OLE->LastError; 
 
$Services = $WMI->ConnectServer($host) ||
 die "Cannot access WMI on remote machine: ", Win32::OLE->LastError; 

# Gather Computer System Information
 
$sys_set = $Services->InstancesOf("Win32_ComputerSystem");
foreach $sys (in($sys_set)) 
 {  
  $system_name         = $sys->{'Caption'};
  $system_type         = $sys->{'SystemType'};
  $system_manufacturer = $sys->{'Manufacturer'};
  $system_model        = $sys->{'Model'};
 }
 

# Gather Processor Information
$processor_set = $Services->InstancesOf("Win32_Processor");
foreach $proc (in($processor_set)) 
 {
  $proc_description    = $proc->{'Caption'};
  $proc_manufacturer   = $proc->{'Manufacturer'};
  $proc_mhz            = $proc->{'CurrentClockSpeed'};
 }


# Gather BIOS Information

#$bios_set = $Services->InstancesOf("Win32_BIOS");
#foreach $bios (in($bios_set)) 
# {  
#  $bios_info       = $bios->{'Version'};
# }

# Gather Time Zone Information

$loc_set = $Services->InstancesOf("Win32_TimeZone");
foreach $loc (in($loc_set)) 
 {
  $loc_timezone      = $loc->{'StandardName'};  
 }

# Gather Operating System Information

$os_set = $Services->InstancesOf("Win32_OperatingSystem");
foreach $os (in($os_set)) 
 {
  $os_name         = $os->{'Caption'};
  $os_version      = $os->{'Version'};
  $os_manufacturer = $os->{'Manufacturer'};
  $os_build        = $os->{'BuildNumber'};
  $os_directory    = $os->{'WindowsDirectory'};
  $os_locale       = $os->{'Locale'}; 
  $os_totalmem     = $os->{'TotalVisibleMemorySize'};
  $os_freemem      = $os->{'FreePhysicalMemory'};
  $os_totalvirtmem = $os->{'TotalVirtualMemorySize'};
  $os_freevirtmem  = $os->{'FreeVirtualMemory'};
  $os_pagefilesize = $os->{'SizeStoredInPagingFiles'}; 
 }

$tempstuff = $Services->InstancesOf("Win32_BaseBoard");

foreach my $sysvar (in($tempstuff)){
        $bbcaption                      = $sysvar ->{'Caption'};
        $bbconfigoptions        = $sysvar ->{'ConfigOptions'};
        $dddepth                        = $sysvar ->{'Depth'};  
        $bbheight                       = $sysvar ->{'Height'};
        $bbwidth                        = $sysvar ->{'Width'};
        $bbweight                       = $sysvar ->{'Weight'};
        $bbmanufacturer         = $sysvar ->{'Manufacturer'};
        $bbmodel                        = $sysvar ->{'Model'};
        $bbname                         = $sysvar ->{'name'};
        $bbpartnumber           = $sysvar ->{'PartNumber'};
        $bbproduct                      = $sysvar ->{'Product'};
        $bbrequiredescript      = $sysvar ->{'RequirementsDescription'};
        $bbsku                          = $sysvar ->{'SKU'};
        $bbslotlayout           = $sysvar ->{'SlotLayout'};
        $bbtag                          = $sysvae ->{'Tag'};
}

# Now convert the system's Locale to a string
# Use the Rfc1766 Database stored in the Registry as a lookup table

$main::HKEY_LOCAL_MACHINE->Open("SOFTWARE\\Classes\\MIME\\Database\\Rfc1
766",$Rfc1766);
$Rfc1766->GetValues(\%Values);
foreach $key (keys %Values)
 {
  $key = $Values{$key};
  if ($$key[0] eq $os_locale)
   {
    ($lang, $country) = split(/\;/, $$key[2]);
    last;
   } 
 }

print "System Summary Information\n";
print "--------------------------\n";
print "OS Name\t\t\t\t$os_name\n";
print "Version\t\t\t\t$os_version Build $os_build\n";
print "OS Manufacturer\t\t\t$os_manufacturer\n";
print "System Name\t\t\t$system_name\n";
print "System Manufacturer\t\t$system_manufacturer\n";
print "System Model\t\t\t$system_model\n";
print "System Type\t\t\t$system_type\n";
print "Processor\t\t\t$proc_description $proc_manufacturer ~$proc_mhz
Mhz\n";
#print "BIOS Version\t\t\t$bios_info\n";
print "Windows Directory\t\t$os_directory\n";
print "Locale\t\t\t\t$country\n";  
print "Time Zone\t\t\t$loc_timezone\n";
print "Total Physical Memory\t\t$os_totalmem KB\n";
print "Available Physical Memory\t$os_freemem KB \n";
print "Total Virtual Memory\t\t$os_totalvirtmem KB\n";
print "Available Virtual Memory\t$os_freevirtmem KB\n";
print "Page File Space\t\t\t$os_pagefilesize KB\n";
print("Caption is $bioscaption\n");
print("Base Board caption is $bbcaption\n");
print("Base Board configuration options @$bbconfigoptions\n");
print("Base Board depth is $bbdepth inches\n");
print("Base Board height is $bbheight inches\n");
print("Base Board width is $bbwidth inches\n");
print("Base Board weight is $bbweight lbs\n");
print("Base Board manufacturer is $bbmanufacturer\n");
print("Base Board model is $bbmodel\n");
print("Base Board name is $bbname\n");
print("Base Board part number is $bbpartnumber\n");
print("Base Board product is $bbproduct\n");
print("Base Board requirements descriptioncaption is
$bbrequiredescript\n");
print("Base Board SKU is $bbsku\n");
print("Base Board slot layout is $bbslotlayout\n");
print("Base Board Tag is $bbtag\n");

#F:\perl\practice\Win32OLE\wmi>perl wmi6.pl
#System Summary Information
#--------------------------
#OS Name                         Microsoft Windows XP Professional
#Version                         5.1.2600 Build 2600
#OS Manufacturer                 Microsoft Corporation
#System Name                     JOHNATHLONXPM
#System Manufacturer             Acer
#System Model                    Ferrari 3000
#System Type                     X86-based PC
#Processor                       x86 Family 6 Model 10 Stepping 0
AuthenticAMD ~1857 Mhz
#Windows Directory               C:\WINDOWS
#Locale                          English (United States)
#Time Zone                       Malay Peninsula Standard Time
#Total Physical Memory           1047024 KB
#Available Physical Memory       657196 KB
#Total Virtual Memory            2097024 KB
#Available Virtual Memory        2054168 KB
#Page File Space                 1205864 KB
#Caption is
#Base Board caption is Base Board
#Base Board configuration options
#Base Board depth is  inches
#Base Board height is  inches
#Base Board width is  inches
#Base Board weight is  lbs
#Base Board manufacturer is Acer,Inc.
#Base Board model is
#Base Board name is Base Board
#Base Board part number is
#Base Board product is Aspire 1450
#Base Board requirements descriptioncaption is
#Base Board SKU is
#Base Board slot layout is
#Base Board Tag is

> -----Original Message-----
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On 
> Behalf Of andrew Black
> Sent: Monday, March 06, 2006 4:20 AM
> To: perl-win32-users
> Subject: Re: Battery info on a laptop
> 
> 
> $Bill Luebkert wrote:
> > 
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisd
> > k/wmi/computer_system_hardware_classes.asp
> > 
> > ...
> > 
> > Power Classes
> > 
> > The Power subcategory groups classes that represent power supplies, 
> > batteries, and events related to these devices.
> > 
> > Class                               Description
> > Win32_AssociatedBattery     Relates a logical device and 
> the battery it is using.
> > Win32_Battery                       Represents a battery 
> connected to the computer system.
> > Win32_CurrentProbe          Represents the properties of a 
> current monitoring sensor (ammeter).
> > Win32_PortableBattery               Represents the 
> properties of a portable battery, such as one used for a 
> notebook computer.
> > Win32_PowerManagementEvent  Represents power management 
> events resulting from power state changes.
> > Win32_UninterruptiblePowerSupply    Represents the 
> capabilities and management capacity of an uninterruptible 
> power supply (UPS).
> > Win32_VoltageProbe          Represents the properties of a 
> voltage sensor (electronic voltmeter).
> 
> 
> Hi
> That looks as though it has the info I want,. but I am afraid I don't 
> know enough about Win32 programming to get the info.
> Could you point me to an example.
> 
> Sorry about that.
> 
> Andrew
> 
> _______________________________________________
> Perl-Win32-Users mailing list 
> [email protected]
> To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
> 

_______________________________________________
Perl-Win32-Users mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to