Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
874 B

  1. # How much RAM is there on a machine ?
  2. use strict;
  3. use Win32::OLE;
  4. use Win32::OLE::Enum;
  5. use Win32::OLE::Const 'Microsoft WMI Scripting V1.1 Library';
  6. use Getopt::Std;
  7. # below is the old version if you should need it.
  8. # use Win32::OLE::Const 'Microsoft WBEM Scripting V1.0 Library';
  9. use vars qw($locator $serv $opt_h $objs $tmp);
  10. ((2 == @ARGV) || (0 == @ARGV)) || die "Useage: [-h host] \n";
  11. getopts('h:') || die "Useage: [-h host] \n";
  12. $locator = Win32::OLE->new('WbemScripting.SWbemLocator') or die "loc\n";
  13. $serv = $locator->ConnectServer(($opt_h) ? $opt_h : '.');
  14. $serv->{security_}->{ImpersonationLevel} = wbemImpersonationLevelImpersonate;
  15. $objs = $serv->ExecQuery("Select TotalPhysicalMemory From Win32_LogicalMemoryConfiguration");
  16. foreach (Win32::OLE::Enum->new($objs)->All())
  17. {
  18. print "$_->{TotalPhysicalMemory} KB\n";
  19. }