Enabling and Disabling Disk Quotas

Microsoft® Windows® 2000 Scripting Guide

microsoft windows 2000 scripting guide

« Previous | Next »   

You can enable and disable disk quotas on a volume by toggling the value of the DiskQuotaControl QuotaState property. When the value of the QuotaState property is set to 2, quotas are enabled and enforced; users who exceed their quota limit will not be able to save additional data to the drive. When the value of the QuotaState property is set to 1, quotas will be enabled but not enforced. This means that users who exceed their quota limit will still be able to save data to the drive. When the value of the QuotaState property is set to 0, quotas are disabled.

When you disable quotas on a volume, you do not discard previous quota information. Instead, you simply stop the Windows 2000 operating system from enforcing disk quotas and tracking disk space usage.

For example, suppose you have a volume with the quota entries shown in Table 10.5.

Table 10.5   Sample Disk Quota Entries

NameQuota LimitWarning Level
KMeyer100 MB90 MB
PAckerman200 MB180 MB
RWilliams400 MB350 MB

If you disable disk quotas on this volume, these quota entries are not deleted. If you later decide to re-enable disk quotas, each of the entries shown in Table 10.5 is restored, along with the appropriate quota limit and warning level.

Scripting Steps

Listing 10.10 contains a script that enables disk quotas for drive C on a computer. To carry out this task, the script must perform the following steps:

  1. Create a constant named ENABLE_QUOTAS and set the value to 2. This constant will be used to enable and enforce disk quotas on the volume.
  2. Create an instance of the DiskQuota1 object.
  3. Use the Initialize method to indicate that disk quotas should be enabled on drive C.

    The Initialize method requires the following two parameters:

    • The drive letter of the drive where disk quotas are being enabled (in this case, C).
    • The value True, indicating that the drive should be initialized for read/write access.
  4. Set the value of the QuotaState property to 2, using the constant ENABLE_QUOTAS.

Listing 10.10   Enabling Disk Quotas

1 2 3 4 
Const ENABLE_QUOTAS = 2 Set colDiskQuotas = CreateObject("Microsoft.DiskQuota.1") colDiskQuotas.Initialize "C:\", True colDiskQuotas.QuotaState = ENABLE_QUOTAS

send us your feedback Send us your feedback « Previous | Next »   


Microsoft Windows 2000 Scripting Guide(c) Automating System Administration 2003
Microsoft Windows 2000 Scripting Guide(c) Automating System Administration 2003
ISBN: N/A
EAN: N/A
Year: 2004
Pages: 635

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net