Enabling and Disabling Disk Quotas
Microsoft® Windows® 2000 Scripting Guide
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
Name |
Quota Limit |
Warning Level |
---|---|---|
KMeyer |
100 MB |
90 MB |
PAckerman |
200 MB |
180 MB |
RWilliams |
400 MB |
350 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:
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.
Create an instance of the DiskQuota1 object.
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.
Set the value of the QuotaState property to 2, using the constant ENABLE_QUOTAS.
Listing 10.10 Enabling Disk Quotas
1 2 3 4 |
|