VBScript disk quota program - whats up?

Reply

Join Date: Jan 2004
Posts: 35
Reputation: QKSTechTrainee is on a distinguished road 
Solved Threads: 0
QKSTechTrainee's Avatar
QKSTechTrainee QKSTechTrainee is offline Offline
Light Poster

VBScript disk quota program - whats up?

 
1
  #1
Jan 8th, 2004
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


Reply With Quote Quick reply to this message  
Join Date: Feb 2003
Posts: 793
Reputation: Paladine has a spectacular aura about Paladine has a spectacular aura about Paladine has a spectacular aura about 
Solved Threads: 26
Team Colleague
Paladine's Avatar
Paladine Paladine is offline Offline
Master Poster

Re: VBScript disk quota program - whats up?

 
0
  #2
Jan 9th, 2004
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
Assistant Manager, Pharmacy Informatics
Wordpress Learning Blog
Updated : ASP.Net Login Code
Reply With Quote Quick reply to this message  
Join Date: Jan 2004
Posts: 35
Reputation: QKSTechTrainee is on a distinguished road 
Solved Threads: 0
QKSTechTrainee's Avatar
QKSTechTrainee QKSTechTrainee is offline Offline
Light Poster

Re: VBScript disk quota program - whats up?

 
0
  #3
Jan 9th, 2004
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?
Reply With Quote Quick reply to this message  
Join Date: Feb 2003
Posts: 793
Reputation: Paladine has a spectacular aura about Paladine has a spectacular aura about Paladine has a spectacular aura about 
Solved Threads: 26
Team Colleague
Paladine's Avatar
Paladine Paladine is offline Offline
Master Poster

Re: VBScript disk quota program - whats up?

 
0
  #4
Jan 10th, 2004
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!?!
Assistant Manager, Pharmacy Informatics
Wordpress Learning Blog
Updated : ASP.Net Login Code
Reply With Quote Quick reply to this message  
Join Date: Jan 2004
Posts: 35
Reputation: QKSTechTrainee is on a distinguished road 
Solved Threads: 0
QKSTechTrainee's Avatar
QKSTechTrainee QKSTechTrainee is offline Offline
Light Poster

Re: VBScript disk quota program - whats up?

 
0
  #5
Jan 12th, 2004
Thanks Paladine - all help gratefully received
Reply With Quote Quick reply to this message  
Join Date: Feb 2003
Posts: 793
Reputation: Paladine has a spectacular aura about Paladine has a spectacular aura about Paladine has a spectacular aura about 
Solved Threads: 26
Team Colleague
Paladine's Avatar
Paladine Paladine is offline Offline
Master Poster

Re: VBScript disk quota program - whats up?

 
0
  #6
Jan 12th, 2004
No problem Dude!Win32 Scripting

Good luck!
Assistant Manager, Pharmacy Informatics
Wordpress Learning Blog
Updated : ASP.Net Login Code
Reply With Quote Quick reply to this message  
Join Date: Mar 2004
Posts: 1
Reputation: Spear is an unknown quantity at this point 
Solved Threads: 0
Spear Spear is offline Offline
Newbie Poster

Re: VBScript disk quota program - whats up?

 
0
  #7
Mar 25th, 2004
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.
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 1
Reputation: TimMunro is an unknown quantity at this point 
Solved Threads: 0
TimMunro TimMunro is offline Offline
Newbie Poster

Re: VBScript disk quota program - whats up?

 
0
  #8
Dec 16th, 2004
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")
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Visual Basic 4 / 5 / 6 Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC