Display quota usage for users on a drive (VBScript)

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 VBScript code from this site.

' From the book, "Windows XP Cookbook"
' ISBN: 0596007256

' ------ SCRIPT CONFIGURATION ------
strComputer = "."
strDrive = "<Drive>" ' e.g. D:
' ------ END CONFIGURATION ---------
set objWMI = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
set colQuotas = objWMI.ExecQuery("select * from Win32_DiskQuota " & _
 "where QuotaVolume = 'Win32_LogicalDisk.DeviceID=""" & strDrive & """'")
for each objQuota in colQuotas
 WScript.Echo "User: "& objQuota.User
 WScript.Echo " Volume: "& objQuota.QuotaVolume
 WScript.Echo " Quota Limit: " & _
 objQuota.Limit / 1024 / 1024 & "MB"
 WScript.Echo " Warning Limit: " & _
 objQuota.WarningLimit / 1024 / 1024 & "MB"
 WScript.Echo " Disk Space Used: " & _
 objQuota.DiskSpaceUsed / 1024 / 1024 & "MB"
 WScript.Echo ""
next

This code has been viewed 1139 times.

New from the creators of TechTasks.com: StatSheet.com