Managing Disk Quotas on the NTFS File System

Microsoft® Windows® 2000 Scripting Guide

microsoft windows 2000 scripting guide

« Previous | Next »   

Disk quotas are an integral part of the NTFS file system. When a file or a folder is created on a volume formatted with NTFS, that item is assigned an owner (typically the user who created the item). NTFS obtains the user ID of the file owner and stores that information in the file or folder s Standard Information attribute. This attribute tallies all the disk space allocated to the file or folder. NTFS then locates the quota entry for that user and determines whether the new allocation of disk space causes the user to exceed the assigned quota. If it does, NTFS then takes the appropriate steps, which can include logging an entry in the System event log or preventing the user from creating the file or folder. As the file or folder changes size, NTFS updates the quota control entry to reflect the total disk space used by the user.

Disk quotas are not configured on a computer-wide basis, but are instead tied to individual NTFS volumes. Each drive has separate quota settings, and the actions you take on one volume do not affect the other volumes.

For example, a computer might have a single hard disk divided into three volumes: drives C, D, and E. Each of these drives has separate quota settings. You could enable disk quotas on drives C and D, but disable them on drive E. Likewise, you could grant users 50 MB of disk space on drive C and 100 MB of disk space on drive D.

When managing disk quotas on a computer, the actions you take on one volume do not affect the other volumes in any way. If you allocate User A 50 MB of disk space on drive C, this does not also give User A 50 MB of disk space on drives D and E. If you disable disk quotas on drive D, quotas remain enabled on drives C and E.

In addition to allocating disk space, you can specify a quota warning level, the amount of disk space use that triggers an alert (an event recorded in the System event log informing you that a user is nearing the quota). You can also determine which of the following actions the system takes if a user exceeds the quota:

  • Take no action at all.
  • Record an event in the System event log.
  • Deny the user the right to store additional data until he or she has removed enough files to get back under the quota.

The Windows 2000 operating systems include an Automation object the DiskQuotaControl object that can be used to create and manage disk quotas on a volume. The one limitation of this object is that it must be used locally. You must run the script on the computer where the disk quota entry is created, and you cannot use the DiskQuotaControl object to create quota entries or manage quota settings on remote volumes.

Note

  • You can use the WshController object to run the script on a remote computer, and thus create quota entries on a remote computer. For more information about the WshController object, see "WSH Primer" in this book.

In addition, the DiskQuotaControl object can retrieve information only for one volume at a time. After creating an instance of the object, you must use the Initialize method and pass it the drive letter of the volume you want to work with. (You cannot return a collection consisting of all the volumes on the computer and then manage the quota settings for each of these volumes all at once.) For example, the following code sample allows you to work with disk quotas on drive C:

Set colDiskQuotas = CreateObject("Microsoft.DiskQuota.1") colDiskQuotas.Initialize "C:\", True 

To work with a second volume (such as drive D), you will have to call the Initialize method a second time, passing the drive letter of the new volume.

colDiskQuotas.Initialize "D:\", True 

After calling this method, you will be able to work only with disk quotas on drive D. To work with quotas on drive C again, you would need to call the Initialize method a third time, once again passing the method the drive letter for drive C.


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