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.

32 lines
884 B

  1. # list free space on all drives
  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);
  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 FreeSpace, DeviceID From Win32_LogicalDisk");
  16. print "Free Space (bytes)\n";
  17. foreach (Win32::OLE::Enum->new($objs)->All())
  18. {
  19. print "$_->{DeviceID}\:\t $_->{FreeSpace}\n";
  20. }