943,518 Members | Top Members by Rank

Ad:
Jan 8th, 2004
1

VBScript disk quota program - whats up?

Expand Post »
Hello - here's my problem - trying to set up a lil bit of code that checks win2k disk quota and warns user if they are approaching their disk space threshold.


here's the code - (cut down for simplicity - this version doesnt really do much but should work)

Dim vol, quotauser
Set vol = CreateObject("Microsoft.DiskQuota.1")
vol.Initialize "C:\", false
quotauser = vol.finduser("insert user name here")
if quotauser.quotaused >= quotauser.threshold then
msgbox("Warning - nearing disk space limit")
end if



ok - so - why won't this work? - on running the script (by double-clicking the .vbs icon on my desktop cos I aint running it over our net til I know it works safely) - I get the following error message from Windows Script Host

Line:4
Char:1
Error: Object doesn't support this property or method
Code: 800A01B6

weird - especially since I found the finduser method of the diskquotacontrol object right there on msdn site - so - anyone got any ideas?

Thanks


Similar Threads
Reputation Points: 46
Solved Threads: 0
Light Poster
QKSTechTrainee is offline Offline
35 posts
since Jan 2004
Jan 9th, 2004
0

Re: VBScript disk quota program - whats up?

Don't have the answer but here is some related script that may point you in the right direction.

Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. Author: Jason Tanem
  2.  
  3. Description:
  4.  
  5. This script reads in the names of drives and sends an email warning via Outlook if finds that a drive is below 2.5 GB free.
  6. Script:
  7.  
  8. '= This script reads in the names of drives =
  9. '= <vDriveList> and sends an email warning via =
  10. '= Outlook if finds that a drive is below 2.5 GB =
  11. '= of free space. =
  12. '= =
  13. '= The text file <vDriveLlist> format should contain =
  14. '= one drive entry per line as follows: =
  15. '= =
  16. '= C =
  17. '= D =
  18. '= \\server\resource name =
  19. '==============
  20.  
  21. 'Written by Jason Tanem
  22.  
  23. '------------Declarations-------
  24. dim vFileSys, vShell, vLowIndicator, vDrv
  25. dim vDrvFree, vOutlook, vMessage, vMailTo
  26. dim vDriveList, vOpenText, vTextLine
  27.  
  28. vDriveList = "C:\Temp\Shares.txt"
  29.  
  30. '-------------Functions------
  31.  
  32. 'Boolean for space above or below 2.5 GB
  33.  
  34. Function FreeSpaceStatus(drvPath)
  35. set vFileSys = CreateObject("Scripting.FileSystemObject")
  36. set vDrv = vFileSys.GetDrive(drvPath)
  37. vLowIndicator = "OK"
  38.  
  39. If FormatNumber(((vDrv.FreeSpace/1024)/1024)/1024, 0) < 2.5 Then
  40. vLowIndicator = "Low"
  41. End If
  42.  
  43. FreeSpaceStatus = vLowIndicator
  44. End Function
  45.  
  46.  
  47. 'This function returns drive free space in GB
  48. '-----------
  49.  
  50. Function FreeSpace(drvPath)
  51. Set vFileSYs = CreateObject("Scripting.FileSystemObject")
  52. Set vDrv = vFileSys.GetDrive(drvPath)
  53. vDrvFree = FormatNumber(((vDrv.FreeSpace/1024)/1024)/1024, 2) & " GB"
  54. FreeSpace = vDrvFree
  55. End Function
  56.  
  57. '------------Main------
  58. Set vFileSys = CreateObject("Scripting.FileSystemObject")
  59. Set vOpenText = vFileSys.OpenTextFile(vDriveList)
  60.  
  61. Do While vOpenText.AtEndOfStream <> True
  62. vTextLine = vOpenText.ReadLine
  63.  
  64. If FreeSpaceStatus(vTextLine) = "Low" Then
  65. 'Create and send the email by calling on Outlook via COM
  66. '----------------
  67.  
  68. Set vOutlook = CreateObject("Outlook.Application")
  69. Set vMessage = vOutlook.CreateItem(0)
  70.  
  71. With vMessage
  72. Set vMailTo = vMessage.Recipients.Add("jptanem@mapllc.com")
  73. vMailTo.Type = 1
  74. .Subject = "Low drive space on network resource"
  75. .Body = vTextLine & " is down to " & FreeSpace(vTextLine)
  76. .Importance = 2
  77. .Send
  78. End With
  79. End If
  80. Loop
  81.  
  82. 'Clean Up
  83. '---
  84.  
  85. set vFileSys = Nothing
  86. Set vShell = Nothing
  87. Set vOpenText = Nothing
  88. Set vOutlook = Nothing
  89. Set vMessage = Nothing
  90. WScript.Quit
Team Colleague
Reputation Points: 211
Solved Threads: 27
Master Poster
Paladine is offline Offline
793 posts
since Feb 2003
Jan 9th, 2004
0

Re: VBScript disk quota program - whats up?

Thanks Paladine - that helps me with another problem I wanted to sort out, but doesnt really help with interfacing the script to DiskQuota. I want ultimately to include this script in the users login script ( over 1000 users on this network) so they can be notified on login of their personal disk space status. any ideas?
Reputation Points: 46
Solved Threads: 0
Light Poster
QKSTechTrainee is offline Offline
35 posts
since Jan 2004
Jan 10th, 2004
0

Re: VBScript disk quota program - whats up?

QkSTechTrainee;

Sorry I don't have any other ideas at the moment, but I can post the website I got that script from, it may have something else that can help.

Problem is, I am at work and the site address is at home, (google was no help) so I will post back later on...k!?!
Team Colleague
Reputation Points: 211
Solved Threads: 27
Master Poster
Paladine is offline Offline
793 posts
since Feb 2003
Jan 12th, 2004
0

Re: VBScript disk quota program - whats up?

Thanks Paladine - all help gratefully received
Reputation Points: 46
Solved Threads: 0
Light Poster
QKSTechTrainee is offline Offline
35 posts
since Jan 2004
Jan 12th, 2004
0

Re: VBScript disk quota program - whats up?

No problem Dude!Win32 Scripting

Good luck!
Team Colleague
Reputation Points: 211
Solved Threads: 27
Master Poster
Paladine is offline Offline
793 posts
since Feb 2003
Mar 25th, 2004
0

Re: VBScript disk quota program - whats up?

set objDiskQuota=Createobject("Microsoft.Diskquota.1")
objDiskQuota.Initialize "D:\", True
objDiskQuota.LogQuotaThreshold =True
set objUser=objDiskQuota.FindUser("domain\" & "username")

QuotaLimit = objUser.QuotaLimit / 1048576
PercentageQuotaUsed = int(100*(objUser.QuotaUsed / objUser.QuotaLimit ))

The Above works fine on our webfarm for showing website quota's so should work fine for you as well.

Diskquota's are dodgy as hell btw I have enountered many exception errors while writing a perl version of the above plus we had problems with the finduser not finding the user till the 2nd attempt with no reason why.
Make sure you test the user exists then loop the finduser part to get around this.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Spear is offline Offline
1 posts
since Mar 2004
Dec 16th, 2004
0

Re: VBScript disk quota program - whats up?

Quote originally posted by QKSTechTrainee ...
Hello - here's my problem - trying to set up a lil bit of code that checks win2k disk quota and warns user if they are approaching their disk space threshold.


here's the code - (cut down for simplicity - this version doesnt really do much but should work)

Dim vol, quotauser
Set vol = CreateObject("Microsoft.DiskQuota.1")
vol.Initialize "C:\", false
quotauser = vol.finduser("insert user name here")
if quotauser.quotaused >= quotauser.threshold then
msgbox("Warning - nearing disk space limit")
end if



ok - so - why won't this work? - on running the script (by double-clicking the .vbs icon on my desktop cos I aint running it over our net til I know it works safely) - I get the following error message from Windows Script Host

Line:4
Char:1
Error: Object doesn't support this property or method
Code: 800A01B6

weird - especially since I found the finduser method of the diskquotacontrol object right there on msdn site - so - anyone got any ideas?

Thanks
On the 4th line it reads:
quotauser = vol.finduser("insert user name here")

It should read:

set quotauser = vol.finduser("insert user name here")
Reputation Points: 10
Solved Threads: 0
Newbie Poster
TimMunro is offline Offline
1 posts
since Dec 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Visual Basic 4 / 5 / 6 Forum Timeline: VB4 Printer Object or Packing Printlines & BTRIEVE
Next Thread in Visual Basic 4 / 5 / 6 Forum Timeline: how to select folder using commondialog in visual basic





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC