Configure disk quota for a user (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;
$strComputer = '.';
$strUser = '<User>';
# e.g. rallen
$strUserDomain = '<Domain>';
# e.g. AMER
$strDrive = '<Drive>';
# e.g. D:
$intLimit = 1024 * 1024 * 600;
# = 600 MB
$intWarning = 1024 * 1024 * 350;
# = 350 MB
# ------ END CONFIGURATION ---------
$objWMI = Win32::OLE->GetObject('winmgmts:\\\\' . $strComputer . '\\root\\cimv2');
$objDisk = $objWMI->Get('Win32_LogicalDisk.DeviceID=\'' . $strDrive . '\'');
print 'Found disk ' . $objDisk->Caption, "\n";
$objUser = $objWMI->Get('Win32_Account.Domain=\'' . $strUserDomain . '\',Name=\'' . $strUser . '\'');
print 'Found user ' . $objUser->Name, "\n";
$objQuota = $objWMI->Get('Win32_DiskQuota.QuotaVolume=' . '\'Win32_LogicalDisk.DeviceID="' . $strDrive . '"\',' . 'User=\'Win32_Account.Domain="' . $strUserDomain . '",Name="' . $strUser . '"\'');
$objQuota->{Limit} = $intLimit;
$objQuota->{WarningLimit} = $intWarning;
$objQuota->PutWScript->Echo('Set quota for user ' . $objUser->Name);
|
This code has been viewed 783 times.
|
New from the creators of TechTasks.com:
StatSheet.com
|