Compress a Volume (Perl)
This code can be found in
Chapter 7 of Windows XP Cookbook
Purchase XP Cookbook or Networking Recipes for only $25 plus shipping! While supplies last.
Find out how to download all of the Perl code from this site.
# From the book, "Windows XP Cookbook"
# ISBN: 0596007256
# ------ SCRIPT CONFIGURATION ------
use Win32::OLE qw(in);
$strComputer = '.';
$strDrive = '<Drive>';
# e.g. D:
$boolRecursive = 1;
# ------ END CONFIGURATION ---------
$objWMI = Win32::OLE->GetObject('winmgmts:\\\\' . $strComputer . '\\root\\cimv2');
$colFolder = $objWMI->ExecQuery('select * from Win32_Directory ' . ' where name = \'' . $strDrive . '\\\\\'');
if ($colFolder->Count != 1) {
print "Error: Volume not found.\n";
}
else {
foreach my $objFolder (in $colFolder) {
$intRC = $objFolder->CompressEx($strErrorFile, undef, $boolRecursive);
if ($intRC != 0) {
print 'Error compressing volume: ' . $intRC, "\n";
print 'Stopped on file: ' . $strErrorFile, "\n";
}
else {
print "Successfully compressed volume.\n";
}
}
}
|
This code has been viewed 650 times.
|
New from the creators of TechTasks.com:
StatSheet.com
|