-----------------------------------------------------------

New Message on BDOTNET

-----------------------------------------------------------
From: spark
Message 4 in Discussion


if you simply want the number, use my 
earlier perl code and run the command
 
D:\RoshanJ\work\pl>wmi.pl win32_processor 
-*
1
 AddressWidth = 32
 Architecture = 
0
 Availability = 3
 Caption = x86 Family 15 Model 1 Stepping 
2
 ConfigManagerErrorCode =
 ConfigManagerUserConfig 
=
 CpuStatus = 1
 CreationClassName = 
Win32_Processor
 CurrentClockSpeed = 1804
 CurrentVoltage = 
16
 DataWidth = 32
 Description = x86 Family 15 Model 1 Stepping 
2
 DeviceID = CPU0
 ErrorCleared =
 ErrorDescription 
=
 ExtClock = 100
 Family = 2
 InstallDate 
=
 L2CacheSize = 256
 L2CacheSpeed = 1804
 LastErrorCode 
=
 Level = 15
 LoadPercentage = 0
 Manufacturer = 
GenuineIntel
 MaxClockSpeed = 1804
 Name 
=               
Intel(R) Pentium(R) 4 CPU 1.80GHz
 OtherFamilyDescription 
=
 PNPDeviceID =
 PowerManagementCapabilities 
=
 PowerManagementSupported = 0
 ProcessorId = 
3FEBFBFF00000F12
 ProcessorType = 3
 Revision = 
258
 Role = CPU
 SocketDesignation = Socket 478
 Status 
= OK
 StatusInfo = 3
 Stepping = 
2
 SystemCreationClassName = Win32_ComputerSystem
 SystemName = 
RMZ10F01
 UniqueId =
 UpgradeMethod = 4
 Version = Model 
1, Stepping 2
 VoltageCaps =
 
here is the perl code again, for 
you:
 
use Win32;
use Win32::OLE qw (in);
 
$system = ".";
$classname = "Win32_Process";
@props = 
("name");
%prop_value=();
$namespace = "root/cimv2";
$call = 
"instances";
 
sub list_instances {
 $serv = 
Win32::OLE->GetObject("winmgmts://$system/$namespace");
 $objs = 
$serv->InstancesOf("$classname");
 $i = 1;
 foreach $obj 
(in($objs)) {
  $str = "$i ";
  if ($all_props) 
{
   foreach $prop (in($obj->{Properties_})) 
{
    $str = "$str\n $prop->{name} = 
$obj->{$prop->{name}}";
   }
   $str = 
"$str\n"
  }
  else{
   foreach 
$prop (in(@props)) {
    $str = 
"$str\t$obj->{$prop}";
   }
  }
  $str 
= "$str\n";
  print $str;
  $i = $i + 
1;
 }
}
 
sub list_classinfo {
 $obj = 
Win32::OLE->GetObject("winmgmts://$system/$namespace:$classname");
 print 
"$classname Properties : -----------------------------\n";
 $i = 
1;
 foreach $prop (in($obj->{Properties_})) {
  print 
"$i\t$prop->{name}\n";
  $i = $i + 1;
 }
 print 
"$classname Methods : -----------------------------\n";
 $i = 
1;
 foreach $m (in($obj->{Methods_})) {
  print 
"$i\t$m->{name}\n";
  $i = $i + 
1;
 }
}
 
sub list_namespaceinfo {
 $serv = 
Win32::OLE->GetObject("winmgmts://$system/$namespace");
 print 
"$namespace Classes : -----------------------------\n";
 $i = 
1;
 foreach $class (in($serv->SubClassesOf())) {
  $path 
= $class->{Path_}->{Path};
  print 
"$i\t$path\n";
  $i = $i + 1;
 }
 print "$classname 
Namespaces : -----------------------------\n";
 $i = 1;
 foreach 
$ns (in($serv->InstancesOf("__NAMESPACE"))) {
  print 
"$i\t$ns->{name}\n";
  $i = $i + 
1;
 }
}
 

sub call_method 
{
 $serv = 
Win32::OLE->GetObject("winmgmts://$system/$namespace");
 
 if 
((scalar keys (%prop_value)) == 0){
  $query="select * from 
$classname";
 } else{
  $query="select * from $classname 
where ";
  $and = "";
  for $key (keys %prop_value) 
{
   $value = 
%prop_value->{$key};
   $query = "$query $and 
$key=\'$value\'";
   $and = 
"and";
  }
 }
 
 print "Query = 
$query\n";
 $objs = $serv->ExecQuery($query);
 $i = 
0;
 foreach $obj (in ($objs)) {
  print "$i 
$obj->{name}->$methodname\n";
  $obj->{$methodname};
  $i 
= $i + 1
 }
}
 
 
 
foreach $arg (in(@ARGV)) 
{
 if ($arg =~ m#/sys:(.*)#) {
  $system = $1;
 } 
elsif ($arg =~ m#@(.*)#) {
  $system = $1;
 } elsif ($arg 
=~ m#\/class\:(.*)#) {
  $classname = $1;
 } elsif ($arg =~ 
m#\-\*#) {
  $all_props = 1;
 } elsif ($arg =~ 
m#\-(.*)=(.*)#) {
  %prop_value->{$1}=$2;
 } elsif ($arg 
=~ m#\-(.*)#) {
  @props[$#props+1]=$1;
 } elsif ($arg =~ 
m#\?#) {
  $call = "classinfo";
 } elsif ($arg =~ m#dir#) 
{
  $call = "dir";
 } elsif ($arg =~ m#(.*)\(.*\)#) 
{
  $methodname = $1;
  $call = "method";
 } 
elsif ($arg =~ m#\/ns\:(.*)#) {
  $namespace = $1;
 } else 
{
  $classname = $arg;
 }
}
 
if ($call eq "instances") 
{
 list_instances();
} elsif ($call eq "dir") 
{
 list_namespaceinfo();
} elsif ($call eq "classinfo") 
{
 list_classinfo();
} elsif ($call eq "method") 
{
 call_method();
}

 
 
 
 

-----------------------------------------------------------

To stop getting this e-mail, or change how often it arrives, go to your E-mail 
Settings.
http://groups.msn.com/BDOTNET/_emailsettings.msnw

Need help? If you've forgotten your password, please go to Passport Member Services.
http://groups.msn.com/_passportredir.msnw?ppmprop=help

For other questions or feedback, go to our Contact Us page.
http://groups.msn.com/contact

If you do not want to receive future e-mail from this MSN group, or if you received 
this message by mistake, please click the "Remove" link below. On the pre-addressed 
e-mail message that opens, simply click "Send". Your e-mail address will be deleted 
from this group's mailing list.
mailto:[EMAIL PROTECTED]

Reply via email to