Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Retrieving quota size for single user problem.

Posted on 2006-06-11
6
787 Views
Last Modified: 2012-05-05
Hi, the following code will enumerate all users and retrieve their disk quota size, Do someone know how can I get disk quota size for just single user? Can I do something like that in sql statment: "Select * from Win32_DiskQuota where user='m' "? I did it but it does not work.

strComputer = "."
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colQuotas = objWMIService.ExecQuery("Select * from Win32_DiskQuota")
For each objQuota in colQuotas
      Response.write "Volume: "& vbTab &  objQuota.QuotaVolume & "<br>"
      Response.write "User: "& vbTab &  objQuota.User& "<br>"
      Response.write "Limit: " & vbTab &  objQuota.Limit      & "<br>"  
      Response.write "Disk Space Used: "& vbTab &  objQuota.DiskSpaceUsed& "<br>"
      response.write "<p>"
Next
0
Comment
Question by:Abdu_Allah
  • 3
  • 3
6 Comments
 
LVL 33

Accepted Solution

by:
hongjun earned 500 total points
ID: 16880892
Try something like this

<%
strComputer = "."
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colQuotas = objWMIService.ExecQuery("Select * from Win32_DiskQuota where User='Win32_Account.Domain=""YOURDOMAIN"",Name=""Administrators""'")
For each objQuota in colQuotas
     Response.write "Volume: "& vbTab &  objQuota.QuotaVolume & "<br>"
     Response.write "User: "& vbTab &  objQuota.User& "<br>"
     Response.write "Limit: " & vbTab &  objQuota.Limit      & "<br>"  
     Response.write "Disk Space Used: "& vbTab &  objQuota.DiskSpaceUsed& "<br>"
     response.write "<p>"
Next
%>


hongjun
0
 
LVL 3

Author Comment

by:Abdu_Allah
ID: 16880956
It seems a good solution but why I got this error:
Error Type:
Microsoft VBScript compilation (0x800A0401)
Expected end of statement
/login.asp, line 21, column 138
Set colQuotas = objWMIService.ExecQuery("Select * from Win32_DiskQuota where User='Win32_Account.Domain=""USER-89C9A"",Name=""m""'"))
0
 
LVL 33

Expert Comment

by:hongjun
ID: 16880968
You got an extra close bracket
Should be

Set colQuotas = objWMIService.ExecQuery("Select * from Win32_DiskQuota where User='Win32_Account.Domain=""USER-89C9A"",Name=""m""'")
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 3

Author Comment

by:Abdu_Allah
ID: 16880969
Ok this is my mistake I put a double brakets it works fine now. thanks.

0
 
LVL 3

Author Comment

by:Abdu_Allah
ID: 16880979
By the way hongjun, this code needs administrative credential to be excuted what if the user(s) that loged in using Windows credential was not administrator! how can I execute this code? any idea?
0
 
LVL 33

Expert Comment

by:hongjun
ID: 16880983
I believe this code is only for Administrators
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…

791 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question