Adding a New Disk Quota Entry

Microsoft® Windows® 2000 Scripting Guide

microsoft windows 2000 scripting guide

« Previous | Next »   

When disk quotas are enabled on a volume, the default quota and the default warning limit are automatically applied to any users who already have files stored on that volume. If a new user stores a file on the volume, a quota entry is created that grants that user the same default values. Administrators do not have to manually create new quota entries each time a new user saves a file on the volume.

However, you might want to assign some users a quota limit different from the default value. For example, you might want to allot graphic artists more disk space. If so, you can wait until a graphic artist has saved a file on the volume (and thus been assigned the default quotas) and then change his or her quota. Alternatively, you can create quota entries for each graphic artist in advance, before the user has saved any files to the volume, and give each of these users the desired quota value.

Scripting Steps

Listing 10.13 contains a script that adds a new entry to the disk quotas on a computer. To carry out this task, the script must perform the following steps:

  1. Create an instance of the DiskQuota1 object.
  2. Use the Initialize method to indicate that the new quota entry should be added to drive C.

    The Initialize method requires the following two parameters:

    • The drive letter of the drive where the quota is added (in this case, C).
    • The value True, indicating that the drive should be initialized for read/write access. By setting this value to False, you can enumerate disk quota entries on the volume but you cannot make any changes (read-only).
  3. Use the AddUser method to create a quota entry for user jsmith from the fabrikam domain. If you are adding a quota entry for a domain user account, be sure to include the name of the domain (for example, fabrikam\jsmith). If you are adding a quota entry for a local user account, be sure to include the name of the computer where the entry is being added (for example, atl-dc-01\jsmith).
  4. Use the Sleep method to pause the script for 5 seconds. This ensures that the new quota entry will be added before you attempt to connect to the new entry and modify the quota limit.
  5. Use the FindUser method to query the quota entry for jsmith from the fabrikam domain.
  6. Set the QuotaLimit for user jsmith from the fabrikam domain to 50,000,000 bytes.

Listing 10.13   Adding a New Disk Quota Entry

1 2 3 4 5 6 
Set colDiskQuotas = CreateObject("Microsoft.DiskQuota.1") colDiskQuotas.Initialize "C:\", True Set objUser = colDiskQuotas.AddUser("fabrikam\jsmith") Wscript.Sleep 5000 Set objUser = colDiskQuotas.FindUser("fabrikam\jsmith") objUser.QuotaLimit = 50000000

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